1. Explanation
Use the explain command to view the execution plan of one of these SQL statements, check whether the SQL statement uses an index, and whether a full table scan is performed. , which can be viewed through the explain command. So we dive deep into MySQL's cost-based optimizer, and we can also get details on many of the access strategies that may be considered by the optimizer, and which strategies are expected to be adopted by the optimizer when running a SQL statement.
To use explain, you only need to add the explain keyword to the original select.
2. Example
mysql> explain select * from servers; +----+-------------+---------+------+---------------+------+---------+------+------+-------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+---------+------+---------------+------+---------+------+------+-------+ | 1 | SIMPLE | servers | ALL | NULL | NULL | NULL | NULL | 1 | NULL | +----+-------------+---------+------+---------------+------+---------+------+------+-------+ 1 row in set (0.03 sec)
The above is the detailed content of How to use the mysql execution plan explain command. For more information, please follow other related articles on the PHP Chinese website!