数据越大,取越后面的记录,差异越大(mysql 5.1不支持上面的带limit的子查询,可以改为innder join)
select count(*) from piwigo_history;
+----------+
| count(*) |
+----------+
| 6783731 |
+----------+
1 row in set (0.00 sec)
mysql> select a.* from piwigo_history as a inner join (select id from piwigo_history order by id limit 6783400,10) as b on
a.id=
b.id order by
a.id;
10 rows in set (1.24 sec)
mysql> select a.* from piwigo_history as a inner join (select id from piwigo_history order by id limit 6783410,10) as b on
a.id=
b.id order by
a.id;
10 rows in set (1.32 sec)
mysql> select a.* from piwigo_history as a inner join (select id from piwigo_history order by id limit 6783420,10) as b on
a.id=
b.id order by
a.id;
10 rows in set (1.34 sec)
直接读取
mysql> select * from piwigo_history order by id limit 6783400,10;
10 rows in set (12.76 sec)
mysql> select * from piwigo_history order by id limit 6783410,10;
10 rows in set (14.33 sec)
mysql> select * from piwigo_history order by id limit 6783420,10;
10 rows in set (13.13 sec)