Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4823260
  • 博文数量: 930
  • 博客积分: 12070
  • 博客等级: 上将
  • 技术积分: 11448
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-15 16:57
文章分类

全部博文(930)

文章存档

2011年(60)

2010年(220)

2009年(371)

2008年(279)

分类: Mysql/postgreSQL

2010-04-16 17:34:36

 delimiter //
 create procedure insert_data() begin declare i INT default 0; while i<5000 do  insert into huge_data values(i,concat("kenthy",i),i%26+1); set i=i+1; end while; end;//
 delimiter ;
mysql> create table if not exists huge_data(id INT UNSIGNED, name VARCHAR(16) not null, age INT UNSIGNED);
select * from  huge_data where id>1000 && id<1002;
大概0.14s
 create table tmp ENGINE=MEMORY select * from huge_data
select * from  tmp where id>1000 && id<1002;
+------+------------+------+
| id   | name       | age  |
+------+------------+------+
| 1001 | kenthy1001 |   14 |
+------+------------+------+
1 row in set (0.00 sec)
mysql> explain extended select * from  tmp where id>1000 && id<1002;
+----+-------------+-------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra       |
+----+-------------+-------+------+---------------+------+---------+------+------+-------------+
|  1 | SIMPLE      | tmp   | ALL  | NULL          | NULL | NULL    | NULL | 5000 | Using where |
+----+-------------+-------+------+---------------+------+---------+------+------+-------------+
1 row in set, 1 warning (0.00 sec)
mysql> explain extended select * from  data_huge where id>1000 && id<1002;
ERROR 1146 (42S02): Table 'test.data_huge' doesn't exist
mysql> explain extended select * from  huge_data where id>1000 && id<1002;
+----+-------------+-----------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table     | type | possible_keys | key  | key_len | ref  | rows | Extra       |
+----+-------------+-----------+------+---------------+------+---------+------+------+-------------+
|  1 | SIMPLE      | huge_data | ALL  | NULL          | NULL | NULL    | NULL | 5000 | Using where |
+----+-------------+-----------+------+---------------+------+---------+------+------+-------------+
1 row in set, 1 warning (0.00 sec)
explain的结果是一样的,只是表不一样
阅读(826) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~