8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

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

9.6.4 MyISAM 表优化9.6.4 MyISAM Table Optimization

为了合并碎片化的行并消除因删除或更新行而产生的浪费空间,请在恢复模式下运行 myisamchk:To coalesce fragmented rows and eliminate wasted space that results from deleting or updating rows, run myisamchk in recovery mode:

$> myisamchk -r tbl_name

您可以通过使用 OPTIMIZE TABLE SQL 语句以同样的方式优化表。OPTIMIZE TABLE 会对表进行修复和索引分析,还会对索引树进行排序,从而加快键查找速度。使用 OPTIMIZE TABLE 时,服务器会完成所有工作,因此不存在实用工具与服务器之间的意外交互的可能性。参见 第 15.7.3.4 节,“OPTIMIZE TABLE 语句”。You can optimize a table in the same way by using the OPTIMIZE TABLE SQL statement. OPTIMIZE TABLE does a table repair and a key analysis, and also sorts the index tree so that key lookups are faster. There is also no possibility of unwanted interaction between a utility and the server, because the server does all the work when you use OPTIMIZE TABLE. See Section 15.7.3.4, “OPTIMIZE TABLE Statement”.

myisamchk 有许多其他选项可以用来提高表的性能:myisamchk has a number of other options that you can use to improve the performance of a table:

  • --analyze 或 -a:执行键分布分析。这通过使连接优化器能够更好地选择表的连接顺序以及使用哪些索引,从而提高连接性能。--analyze or -a: Perform key distribution analysis. This improves join performance by enabling the join optimizer to better choose the order in which to join the tables and which indexes it should use.

  • --sort-index 或 -S:排序索引块。这优化了查找操作,并加快了使用索引的表扫描速度。--sort-index or -S: Sort the index blocks. This optimizes seeks and makes table scans that use indexes faster.

  • --sort-records=index_num 或 -R index_num:根据给定的索引对数据行进行排序。这会使您的数据更加本地化,并可能加快使用此索引的基于范围的 SELECT 和 ORDER BY 操作。--sort-records=index_num or -R index_num: Sort data rows according to a given index. This makes your data much more localized and may speed up range-based SELECT and ORDER BY operations that use this index.

有关所有可用选项的完整说明,请参见 第 6.6.4 节,“myisamchk — MyISAM 表维护工具”。For a full description of all available options, see Section 6.6.4, “myisamchk — MyISAM Table-Maintenance Utility”.