MySQL--SQL execution plan

The execution of sql:

  1. Communication phase
  2. Query cache
  3. The parser performs verification and analysis, and obtains a parse tree based on grammatical caution and lexical analysis
  4. Optimizer, optimize the execution phase to find the best execution method of SQL
  5. Actuator execution plan

Use explain or desc to view the execution plan of sql

Execution plan parameters:

  1. id: the order of sql execution, the larger value is executed first, if the id is the same, the order is executed from top to bottom

  2. select_type: execution type, including the following

    • simple: simple query
    • primary: outermost query
    • subquery: subquery
    • union: join query
    • union result: the result set of the join query
  3. table: the table or alias of the table involved in the query

  4. type: the method of performing data acquisition, value and sorting system>const>eq_ref>ref>range>index>all

  5. partitions: query data partition information

  6. possible_keys: possible indexes

  7. key: the index actually used

  8. key_len: The length of the included column used by the index

  9. rows: Estimate the number of rows that need to be read to find the data

  10. Filtered: The number of rows of the returned result accounts for the percentage of the number of rows read (rows)

  11. extra

Guess you like

Origin blog.csdn.net/huangge1199/article/details/110211684