|  |      1wesley      2016-04-06 11:42:12 +08:00 需要加上 order by item_id | 
|  |      2dongyado      2016-04-06 11:43:52 +08:00 你的查询语句都没用 id,item_id 肯定会全表扫描的啊。。。 | 
|  |      3keakon      2016-04-06 14:21:36 +08:00 没有 where 条件 | 
|      4sghcel      2016-04-06 14:27:35 +08:00  1 select item_id from table_name limit 10000,20 这样就不会全表扫描 具体原因看我的 blog: http://dorid.me/2016/02/03/mysql-limit-performance-optimize/ | 
|      5vincenttone      2016-04-06 14:30:51 +08:00 explain select * from table_name limit 10000,20; explain select * from table_name limit 10000,20 order by id desc; explain select * from table_name where item_id = 1 limit 10000,20; 挨个执行看看,你还需要花 20 分钟研究一下索引到底是什么 | 
|      6rqrq      2016-04-06 14:48:28 +08:00 先加上 order by id desc 试试,还是不行试试: select * from table_name where id < (select min(id) from (select id from table_name order by id desc limit 10000) as tmp) limit 20 | 
|  |      7msg7086      2016-04-06 14:50:42 +08:00  2 MySQL 的分页是先读再丢,所以应该要读了扔了 10 万条记录以后再返回。 我自己是先读 ID 然后再用 ID IN () 去查表返回的。 | 
|  |      8davidzhang      2016-04-06 15:06:43 +08:00 因为你没有用到索引啊 | 
|      9stabc      2016-04-06 15:28:18 +08:00 | 
|  |      10treycheng      2016-04-06 15:33:36 +08:00 这个 limit 10000,20  做分页查询 首先会查处前面 10000 行的所有 select 的内容, 然后丢弃掉 分页查询 一般先查询你目标内容的主键 再通过主键查询目标行 | 
|  |      12ivito OP @dongyado 不会根据 Primary key 直接从从 B 数的左侧或右侧遍历吗,耗时不应该只是个扫描 Primary key 索引的耗时吗 | 
|  |      14jiehuangwei      2016-04-06 17:47:30 +08:00 看到这种SQL,就有想往死里打的冲动。。。。 | 
|  |      15wikimore      2016-04-06 17:50:37 +08:00 你这个 SQL 就是不全表扫  也不会太快  LIMIT 10000,20 | 
|  |      16wwek      2016-04-06 18:15:17 +08:00 大翻页问题 翻页从产品角度优化. 只给下一页 ,获取更多什么的 | 
|  |      22elgoog1970      2016-04-07 11:16:09 +08:00 |