我使用索引的MySQL表。Expain「解釋」的查詢結果在MySQL
我的查詢是這樣
EXPLAIN SELECT * FROM `logs` WHERE userId =288 AND dateTime BETWEEN '2010-08-01' AND '2010-08-27'
我對現場用戶id索引此表的日誌, 並解釋查詢的結果是類似下面。
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE logs ref userId userId 4 const 49560 Using where
的問題是「我的索引是真正有用或沒有?」 ......提前
感謝
@fastmultiplication
我認爲雙方本場索引可能會增加加載在mysql上,因爲將會有很多條目具有唯一的(userId和dateTime)。 我已經嘗試添加兩個userId_dateTime索引和結果是
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE logs ref userId_dateTime userId_dateTime 4 const 63455 Using where
我已經進入詳細有問題,請檢查 – 2010-08-27 07:04:19