MySQL in the implementation plan explain

First, the definition and usage:

  explain to sql execution plan, in front of the sql add keywords to explain

如:explain select * from tbl_emp;

Glossary:

  id: operation sequence [Table]

    Same 1.id, execution sequence table are sequentially performed from the downward

    Different 2.id, id the greater of the first execution

    3.id with the same and different, larger first performed, and then press down sequentially executed from the sequence

  select_type: [query type to distinguish between simple queries, subqueries, the joint inquiry]

    Generally: SIMPLE [short answer most of sql query], PRIMARY [If the query contains any complex sub-queries, the outermost query were marked],

        SUBQUERY [contain sub-queries in the select list or where]

        UNION

        ............. 

  type: the type of access to the best [worst]

      system > const > eq_ref > ref > range > index> ALL

      

                        General reach range level like, preferably up to ref

 

  possible: the display may be applied to index this table, one or more; relates to the field if the query index exists, the index will be listed, but not necessarily actually used by the query.

      Simply put: MySQL speculated theoretically possible to use the index, but not necessarily the actual query

  key: query index actually used, if it is NULL, or not to build or useless, or failure index

    Cover index: select query field and the rear composite index built exactly the same number and order

    If there is no theory, and key appeared , is the use of a covering index

  ref: display the index which column was used

  rows: the smaller the better

  Extra: Do not appear the best, Using filesort [in the document ordering]

Second, the role:

  

 

 Example:

 

Guess you like

Origin www.cnblogs.com/exce-ben/p/12375264.html