合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
> 官网:https://dev.mysql.com/doc/refman/8.0/en/explain-output.html **EXPLAIN** 命令,它可以对`SELECT`语句进行分析,并输出`SELECT`执行的详细信息,以供开发人员针对性优化。 ~~~ mysql> EXPLAIN SELECT * from users where id = 1; +----+-------------+-------+------------+-------+---------------+---------+---------+-------+------+----------+-------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------+------------+-------+---------------+---------+---------+-------+------+----------+-------+ | 1 | SIMPLE | users | NULL | const | PRIMARY | PRIMARY | 8 | const | 1 | 100.00 | NULL | +----+-------------+-------+------------+-------+---------------+---------+---------+-------+------+----------+-------+ 1 row in set (0.02 sec) ~~~ | Column | JSON Name | Meaning | | --- | --- |--- | | id | 1 | `SELECT`标识符 | | select_type | SIMPLE | `SELECT`类型 | | table | users | 查询的表 | | partitions | NULL | 匹配的分区 | | type | const | 联接类型 | | possible_keys | PRIMARY | 可能选择的索引 | | key | PRIMARY | 实际选择的索引 | | key_len | 8 | 所选密钥的长度 | | ref | const | 与索引比较的列 | | rows | 1 | 估计要检查的行数 | | filtered | 100.00 | 按表条件过滤的行百分比 | | Extra | NULL | 附加信息 |