EXPLAIN Select query
suggest changeIn MySQL, EXPLAIN in front of a SELECT shows how the query will be executed. This way you can see whether the query uses an index, or whether adding an index might help.
Example query:
explain select * from user join data on user.test = data.fk_user;
Example result:
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE user index test test 5 (null) 1 Using where; Using index
1 SIMPLE data ref fk_user fk_user 5 user.test 1 (null)
type shows how the table was read, including whether an index was used. possible_keys lists indexes the optimizer considered, or is empty if none exists. key is the index actually used. key_len is the size in bytes of one index item. A lower value packs more items into the same memory, so they can be processed faster. rows is the expected number of rows the query needs to examine; lower is better.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents