newman1234 / SQL_note

0 stars 0 forks source link

order of limit, where, select, order by? #1

Open newman1234 opened 2 years ago

newman1234 commented 2 years ago

where > order by > limit > select

newman1234 commented 2 years ago

order by + limit N 如果 column 有 index,會非常快,即使沒有 index,也會在找到 N 個 result 後 return 結果並不會執行完整個 sort https://dev.mysql.com/doc/refman/5.7/en/limit-optimization.html