user 表共有37条记录
1.select * 无 where 条件
mysql> explain select * from user limit 29,7 \G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: user
type: ALL
possible_keys: NULL
key: NULL
key_len: NULL
ref: NULL
rows: 37
Extra:
2.select * 有 where 条件
mysql> explain select * from user where id > 29 limit 0,7 \G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: user
type: range
possible_keys: PRIMARY
key: PRIMARY
key_len: 4
ref: NULL
rows: 8
Extra: Using where
3.select col_name 有where 条件
mysql> explain select age from user where id > 29 limit 0,7 \G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: user
type: range
possible_keys: PRIMARY
key: PRIMARY
key_len: 4
ref: NULL
rows: 8
Extra: Using where
实际查询耗时对比
mysql> select * from buy_keywords limit 50000,10;
//省略数据显示
10 rows in set (0.16 sec)
mysql> select * from buy_keywords where id > 50000 limit 0,10;
//省略数据显示
10 rows in set (0.03 sec)