Detailed mysql explain ter

This switched: https://blog.csdn.net/u010061060/article/details/52473244

explain  select * from user

 

explain extended select * from user


 

id SELECT identifier. This is a SELECT query sequence number
select_type

SELECT type, which can be any of the following:

  • SIMPLE : Simple SELECT (not using UNION or subqueries)
  • PRIMARY : the outermost SELECT
  • UNION : The second or rear UNION SELECT statement
  • UNION DEPENDENT : UNION in the second SELECT statement or the back, depending on outside of inquiry
  • The RESULT UNION : UNION results
  • SUBQUERY : the first sub-query SELECT
  • SUBQUERY DEPENDENT : the first sub-query SELECT, depending on outside inquiry
  • DERIVED : export table SELECT (FROM clause subqueries)
table

Output line table referenced

type

Join type. Various types of coupling are given below, in accordance with the type ordered from best to worst type:

  • System : Only one line of table (= system table). This is a special case of the const join type.
  • const : Table at most one matching row, which will be read at the start of the query. Because only one row, column values in this row may be considered to optimize the remaining portion is constant. const table quickly because they are read only once!
  • eq_ref : For each combination of rows from the front of the table, reads a line from the table. This is probably the best connection type, except const type.
  • REF : For each combination of rows from the preceding table, all rows matching the index values read from this table.
  • ref_or_null : The connection type as ref, but added the line MySQL can search specifically contain NULL values.
  • index_merge : the coupling type indication index combined optimization method.
  • unique_subquery : The type of the alternative form of ref IN subqueries of the following: value IN (SELECT primary_key FROM single_table WHERE some_expr) unique_subquery is an index lookup function, can completely replace the subquery, more efficient.
  • index_subquery : This type is similar to the coupling unique_subquery. IN subquery can be replaced, but only for the following sub-query in the form of a non-unique index: value IN (SELECT key_column FROM single_table WHERE some_expr)
  • Range : only retrieves a row given range, using an index to select the rows.
  • index : the coupling with ALL the same type, except that only the index tree is scanned. This is usually faster than ALL, because the index file is usually smaller than the data file.
  • ALL : For each combination of rows from the previous table, a full table scan.
possible_keys

It indicates which indexes MySQL could use to find the rows in the table

key Display key (index) MySQL actually decided to use. If you do not select an index, the key is NULL.
key_len Display MySQL decided to use key lengths. If the key is NULL, the length is NULL.
ref Shows which columns or constants are selected together with a key from a table using the row.
rows 显示MySQL认为它执行查询时必须检查的行数。多行之间的数据相乘可以估算要处理的行数。
filtered 显示了通过条件过滤出的行数的百分比估计值。
Extra

该列包含MySQL解决查询的详细信息

  • Distinct:MySQL发现第1个匹配行后,停止为当前的行组合搜索更多的行。
  • Not exists:MySQL能够对查询进行LEFT JOIN优化,发现1个匹配LEFT JOIN标准的行后,不再为前面的的行组合在该表内检查更多的行。
  • range checked for each record (index map: #):MySQL没有发现好的可以使用的索引,但发现如果来自前面的表的列值已知,可能部分索引可以使用。
  • Using filesort:MySQL需要额外的一次传递,以找出如何按排序顺序检索行。
  • Using index:从只使用索引树中的信息而不需要进一步搜索读取实际的行来检索表中的列信息。
  • Using temporary:为了解决查询,MySQL需要创建一个临时表来容纳结果。
  • Using where:WHERE 子句用于限制哪一个行匹配下一个表或发送到客户。
  • Using sort_union(...), Using union(...), Using intersect(...):这些函数说明如何为index_merge联接类型合并索引扫描。
  • Using index for group-by:类似于访问表的Using index方式,Using index for group-by表示MySQL发现了一个索引,可以用来查 询GROUP BY或DISTINCT查询的所有列,而不要额外搜索硬盘访问实际的表。
发布了171 篇原创文章 · 获赞 46 · 访问量 19万+

Guess you like

Origin blog.csdn.net/LHDZ_BJ/article/details/89534024