對索引的使用分析 Explain Select * from user where id>100 /G; 圖1 Explain Select * from user2 where id>100 /G; 圖2 User 表中的數據和 User2 表中的數據是一樣的,索引結構也是一樣的,只不過它們的存儲引擎不同。在圖1中,查詢用到了PRIMARY主鍵索引,而查詢優化器預估的結果大概在65954行左右(實際是131513);在圖2中,查詢卻沒有使用索引,而是全表掃描了,返回的預估結果在131608行(實際是131509)。 Explain Select * from user where id>100 and age>50 /G; 圖3 Explain Select * from user where id>100 and age=50 /G;