場景:資料庫資料500w條資料,分頁查詢100000,10
1. 查詢耗時18.87s
select c.* from t_order where c.id in (select b.id from (select a.id from t_order a limit 4000000,10) b);
2.查詢耗時3.71s
select b.id from (select a.id from t_order a limit 4000000,10) b;
3.查詢耗時0.005s
select c.* from t_order where c.id in (x1,x2,...,x10);
x1 -x2為上面2的結果
按常理 1sql的耗時=2sql的耗時+3sql的耗時
為什么差別那么大?
另外如果分頁查詢如果頁碼特大,各位是如何優化的?
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/32903.html
標籤:MySQL
上一篇:授權DHCP
下一篇:這種情況怎么解決啊
