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

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

10.3.4 外键优化10.3.4 Foreign Key Optimization

如果一个表有很多列,并且你查询许多不同的列组合,那么将不常用的数据拆分到每个只有几列的单独表中,并通过复制主表中的数字 ID 列与主表关联,可能会更加高效。这样,每个小表可以有一个主键以快速查找其数据,并且你可以使用连接操作只查询所需的列集合。根据数据的分布情况,这些查询可能会减少 I/O 并占用更少的缓存内存,因为相关列在磁盘上是连续存放的。(为了最大化性能,查询会尽量从磁盘读取尽可能少的数据块;只有少数几列的表可以在每个数据块中容纳更多的行。)If a table has many columns, and you query many different combinations of columns, it might be efficient to split the less-frequently used data into separate tables with a few columns each, and relate them back to the main table by duplicating the numeric ID column from the main table. That way, each small table can have a primary key for fast lookups of its data, and you can query just the set of columns that you need using a join operation. Depending on how the data is distributed, the queries might perform less I/O and take up less cache memory because the relevant columns are packed together on disk. (To maximize performance, queries try to read as few data blocks as possible from disk; tables with only a few columns can fit more rows in each data block.)