1. Introduction The
explain command can view the execution plan of the SQL statement. When explain is used with SQL statements, MySQL will display information about the execution plan. In other words, MySQL explains how it will process statements, how to join tables, and in what order to join tables.
2. Function The
query analyzer provides functions including analyzing table reading order, data reading operation type, actual use of indexes, and references between tables.
3. The use of
explain is very simple, you only need to add explain command before SQL statement. In addition to select statement, explain can also analyze insert, update and delete statements.
parameter | description |
---|---|
id | The order in which the select clause or operation table is executed |
table | Table name used by the current row |
partitions | Matching partition |
type | Connection type, such as system, const, eq_ref, ref, range, index, all, etc. |
possible_keys | Possible indexes |
key | The index actually used, null means the index is not used |
key_len | Index length used in the query |
ref | Comparison of columns and indexes |
rows | Number of lines scanned |
filtered | The number of selected rows is the percentage of the scanned rows, the ideal result is 100 |
extra | Other additional information |