首页 > 文章列表 > 什么是MySQL中的覆盖索引?

什么是MySQL中的覆盖索引?

mysql
466 2023-04-25

1、查询语句中所需的列在索引中,这样查询结果就可以在索引的数据结构中找到。

2、由于覆盖索引可以减少树木的搜索次数,显著提高查询性能,因此使用覆盖索引是一种常用的性能优化方法。

实例

+----+-------------+------------+------+-----------------------+--------------+---------+-------+------+-------------+
| id | select_type | table      | type | possible_keys         | key          | key_len | ref   | rows | Extra       |
+----+-------------+------------+------+-----------------------+--------------+---------+-------+------+-------------+
|  1 | SIMPLE      | user_group | ref  | group_id,group_id_uid | group_id_uid | 4       | const | 5378 | Using index |
+----+-------------+------------+------+-----------------------+--------------+---------+-------+------+-------------+