Mysql Explain command, mysqlexplain
The MySQL EXPLAIN command is used to query the Execution Plan (QEP) of an SQL statement ). The output results of this command show us how the MySQL optimizer executes SQL statements. This command does not provide any adjustment suggestions, but it can provide important information to help you make optimization decisions.
For more information, see the official documentation:
Http://dev.mysql.com/doc/refman/5.7/en/explain.html
Why does it use explain? If your page returns slow results, you need to use explain to analyze whether your SQL needs optimization.
1/official definition
The EXPLAIN statement provides information about how MySQL executes statements:
The explain statement provides mysql statement execution information.
2/Notes
1) explain statements that can be analyzed include 'select, DELETE, INSERT, REPLACE, and UPDATE.
2) explain can analyze the connection Id of a mysql
3) Use explain to view the index usage and table connection sequence to increase the query speed.
4) if you have an index but are not using it, you need to ANALYZE the TABLE.
Supplement the failure of the mysql index.
1 In the where condition, the index of multiple columns in or2 is not the first part. 3 like queries start with %. 4 fields are strings, the where condition is the number 5 mysql estimates that the full table scan is faster than the index (assuming that the number of data results is known, you can obtain the number of result sets through the index count, because the index is read from 0 (1) Based on the location, T is read when the number of result sets is T, and data blocks are read by full table scan. Assume that the data volume is compact and stored in N blocks, when the full table scan reads N times, generally at T> N, and reaches a certain proportion, whether the ratio can be set to be studied, mysql does not use the index) show session status like 'handler _ read % 'Handler _ read_key: the higher the value, the better. The higher the value indicates the number of times the index is queried. handler_read_rnd_next: the higher the value, the less efficient the query.
3. Output Format
Important:
Whether the index is used for 1 key
2. Number of result sets returned by rows Query
3. Results of filtered filtering.
Rows * filtered gets the number of data entries to be associated. The smaller the filtered, the better the rows.
***
The explain connection Id analyzes the last SQL statement executed. The result is changed. If the statement is not an insert or select statement, an error is returned. show warnings
The above is the Mysql Explain Command introduced by xiaobian. I hope it will be helpful to you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!