explain how to use the index shows a MySql select statement to handle and connection table.
Use in front of the select plus explain it
示例:explain select id , name table where name like 'abc%'
Field | Explanation |
table | Data show that this line of tables on which |
type | Show what type of connection, from best to worst the connection type is const, eq_reg, ref, range, indexhe and ALL |
possible_keys | It shows the possible application of the index in this table. If empty, the index is not possible. May be selected from a suitable statement WHERE clause for the associated domain |
key | Index actually used. If NULL, then do not use the index. In rare cases, MYSQL will choose less than the index optimization. In this case, you can be used in the SELECT statement USE INDEX (indexname) to force the use of an index or with IGNORE INDEX (indexname) to force the index ignored MYSQL |
key_len | Length of the index used. Without loss of accuracy, a length as short as possible |
ref | Which column of the display index is used, if possible, is a constant |
rows | MYSQL must check that the number of rows to return the requested data |
Extra | MYSQL additional information about how to resolve the query. Will be discussed in Table 4.3, but here you can see the bad example of Using temporary and are Using filesort, meaning MYSQL can not use the index, the result is retrieved will be very slow |
extra | Described the significance column returns |
Distinct | Once MYSQL found from row to row with the United match, no longer searched |
Not exists | MYSQL optimized LEFT JOIN, once it finds a match LEFT JOIN standard line, no longer searched |
ange checked for each Record(index map:#) | 没有找到理想的索引,因此对于从前面表中来的每一个行组合,MYSQL检查使用哪个索引,并用它来从表中返回行。这是使用索引的最慢的连接之一 |