天天看點

MYSQL EXPLAIN中的rows代表什麼意思?

這個rows是mysql認為必須要逐行去檢查和判斷的記錄條數

它隻是一個估算值

舉個例子來說,假如有一個語句 select * from t where column_a = 1 and column_b = 2;

全表假設有100條記錄,column_a字段有索引(非聯合索引),column_b沒有索引。

column_a = 1 的記錄有20條, column_a = 1 and column_b = 2 的記錄有5條。

那麼最終查詢結果應該顯示5條記錄。 explain結果中的rows應該是20. 因為這20條記錄mysql引擎必須逐行檢查是否滿足where條件。