1. 程式人生 > >優化order by 語句

優化order by 語句

sin 所有 wid .com src style pan 通過 順序

mysql 中排序方式


有序索引順序掃描直接返回有序數據

explain select customer_id from customer order by store_id\G;

這種方式在使用explain分析查詢的時候顯示為Using Index,不需要額外的排序,效率較高。

技術分享

Filesort排序

所有不是通過索引直接返回排序結果的排序都叫Filesort排序

explain select * from customer order by store_id\G;

這種方式在使用explain分析查詢的時候顯示為Using filesort,

技術分享

優化order by 語句