4 ms·
MySQL can only use one index per query. If you need it be on two or more columns you need a composite index with both columns in, populated from the left. If My
by rythie 17y ago
MySQL can only use one index per query. If you need it be on two or more columns you need a composite index with both columns in, populated from the left. If MySQL finds a column in the index you not keying off (WHERE/SORT etc.) then it will stop processing the index at that point.
The key_len column in the EXPLAIN shows you how far it got through the index, based on the size of the columns. In your case it says 4 which if device id is of type INT it just read one column in the index (though there is probably only one column in that index)