The execution of sql:
- Communication phase
- Query cache
- The parser performs verification and analysis, and obtains a parse tree based on grammatical caution and lexical analysis
- Optimizer, optimize the execution phase to find the best execution method of SQL
- Actuator execution plan
Use explain or desc to view the execution plan of sql
Execution plan parameters:
-
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
-
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
-
table: the table or alias of the table involved in the query
-
type: the method of performing data acquisition, value and sorting system>const>eq_ref>ref>range>index>all
-
partitions: query data partition information
-
possible_keys: possible indexes
-
key: the index actually used
-
key_len: The length of the included column used by the index
-
rows: Estimate the number of rows that need to be read to find the data
-
Filtered: The number of rows of the returned result accounts for the percentage of the number of rows read (rows)
-
extra