1. Limit optimization
Optimization is done by covering indexes and subqueries.
select * from tb_sku limit 0,10;
select * from tb_sku limit 9000000,10;
It took 19.39s to execute this sql
Returning * must be returned to the table. When optimizing, you can only return the id, and you can cover the index.
select id from tb_sku order by id limit 9000000,10;
Time-consuming 11.47s
select * from tb_sku where id in(select id from tb_sku order by id limit 9000000,10);
select s.* from tb_sku s,(select id from tb_sku order by id limit 9000000,10) a where s.id =a.id;
Optimized the time of nearly 9s.