How to use the mysql execution plan explain command

王林
Release: 2023-05-26 17:09:20
forward
1516 people have browsed it

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)
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!