Description of the returned value for performance test of explain SQL statements bitsCN.com
Description of the return value for performance test of explain SQL statements
The returned values of the explain SQL statement performance test are as follows:
Mysql> explain select * from table;
+ ---- + ------------- + ------- + ------ + --------------- + ------ + --------- + ------ + ------- +
| Id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+ ---- + ------------- + ------- + ------ + --------------- + ------ + --------- + ------ + ------- +
Table # display the tables involved in this statement
Type # This column is very important. it shows the category used by the connection and whether the index is used, reflecting the statement quality.
Possible_keys # indicates which index MySQL can use to find rows in the table
Key # displays the keys (Indexes) actually used by MySQL ). If no index is selected, the key is NULL.
Key_len # displays the key length determined by MySQL. If the key is NULL, the length is NULL. The length of the index used. The shorter the length, the better.
Ref # displays the column or constant used with the key to select rows from the table.
Rows # displays the number of rows that MySQL deems necessary for query execution.
Extra # contains detailed information about MySQL queries.
Among them, the type of Explain shows the access type, which is a more important indicator. The result values are from good to bad:
System> const> eq_ref> ref> fulltext> ref_or_null> index_merge> unique_subquery> index_subquery> range> index> ALL (excellent --> difference)
In general, make sure that the query reaches at least the range level, and it is best to reach the ref level. otherwise, performance problems may occur.
BitsCN.com