第37章 分页查询优化 - xiaoboluo768/qianjinliangfang GitHub Wiki

37.2 优化方案

  • 1.普通优化写法
select * from (select emp_no from employees limit 250000,5000) b , employees a where a.emp_no = b.emp_no;
  • 2.业务优化写法
select * from employees where emp_no > #last_emp_no# order by emp_no limit 20;
  • 3.性能对比
mysql> select * from employees limit 250000,5000;
5000 rows in set (1.31 sec)

mysql> select * from (select emp_no from employees limit 250000,5000) b , employees a where a.emp_no = b.emp_no;
5000 rows in set (0.94 sec)

上一篇:第36章 插入意向锁死锁 | 下一篇:第38章 子查询优化——子查询转换为连接