gpt4 book ai didi

mysql - 当查询中未使用字段时,MySQL InnoDB 表中文本字段的大小会影响性能吗

转载 作者:行者123 更新时间:2023-11-29 07:05:03 24 4
gpt4 key购买 nike

我有一个约 500 000 行的 InnoDB 表,该表还在不断增长,我正在努力提高选择查询的性能。

目前该表大约有 2GB 大小,其中大部分大小来自一个存储大量 xml 数据的文本字段。此 xml 数据不经常读取,大多数查询不会选择它。

是否有可能将这些数据移动到一个单独的表中,通过允许更多行同时保存在服务器有限的内存中来加快查询速度?

最佳答案

如果表是 InnoDB 并且您没有在 SELECT 中指定文本字段,则应该没问题。但是,您应该确保主键尽可能小(它位于 gen_clust_index 中)。 Keep in mind that InnoDB performs a clustered index lookup with every query, regardless of non-Indexed Lookups, Indexed Lookups, or Primary Key Lookups .

尽管如此,您问这个问题的事实表明仍然需要考虑相反的情况:将有一些查询在结果集中包含文本字段。

我会确保以下几点:MySQL 数据包、InnoDB 日志文件和 InnoDB 日志缓冲区大小合适。为什么要关注这些设置? Rows of Data must pass through these structures. Make sure that max_allowed_packet is large enough to hold the biggest text field you have in the database at least 10 times. Same goes with InnoDB Log Files and the InnoDB Log Buffer .

关于mysql - 当查询中未使用字段时,MySQL InnoDB 表中文本字段的大小会影响性能吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7851393/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com