文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

MySQL 8.4 参考手册 / 10 优化 / 10.3 优化和索引
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

10.3 优化与索引10.3 Optimization and Indexes

提高SELECT操作性能的最佳方法是在查询中测试的一个或多个列上创建索引。索引条目就像指向表行的指针,使查询能够快速确定哪些行符合WHERE子句中的条件,并检索这些行的其他列值。MySQL 的所有数据类型都可以被索引。The best way to improve the performance of SELECT operations is to create indexes on one or more of the columns that are tested in the query. The index entries act like pointers to the table rows, allowing the query to quickly determine which rows match a condition in the WHERE clause, and retrieve the other column values for those rows. All MySQL data types can be indexed.

虽然为查询中使用的每一列创建索引可能很诱人,但不必要的索引会浪费空间,并且会增加 MySQL 决定使用哪个索引的时间。索引还会增加插入、更新和删除的成本,因为每个索引都必须更新。你必须找到合适的平衡,以使用最佳的索引集合实现快速查询。Although it can be tempting to create an indexes for every possible column used in a query, unnecessary indexes waste space and waste time for MySQL to determine which indexes to use. Indexes also add to the cost of inserts, updates, and deletes because each index must be updated. You must find the right balance to achieve fast queries using the optimal set of indexes.