mysql 中 join_buffer_size 的推荐最大值是多少?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17928366/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the recommended max value for join_buffer_size in mysql?
提问by RafaSashi
I am traying to optimize my temporary data following the recommendation given in the answer to this question: Mysql tmp_table_size max_heap_table_size
我正在按照这个问题的答案中给出的建议优化我的临时数据: Mysql tmp_table_size max_heap_table_size
What is the recommended value for join_buffer_size
and sort_buffer_size
in mysql?
mysql 中join_buffer_size
和的推荐值是sort_buffer_size
多少?
My actual values are:
我的实际价值观是:
join_buffer_size: 128 Kio;
sort buffer size: 512 Kio;
回答by RandomSeed
It is impossible to answer your question in a general case. It really depends on the profile of your queries. Check the manual, learn their purpose, and as they put it nicely:
在一般情况下无法回答您的问题。这实际上取决于您的查询的配置文件。检查手册,了解他们的目的,正如他们所说的那样:
Setting it larger than required globally will slow down most queries that sort. It is best to increase it as a session setting, and only for the sessions that need a larger size. On Linux, there are thresholds of 256KB and 2MB where larger values may significantly slow down memory allocation (...). Experiment to find the best value for your workload.
将其设置为大于全局要求会减慢大多数排序查询。最好将其增加为会话设置,并且仅用于需要更大大小的会话。在 Linux 上,有 256KB 和 2MB 的阈值,其中较大的值可能会显着减慢内存分配 (...)。尝试为您的工作负载找到最佳值。
There is no gain from setting the buffer larger than required to hold each matching row, and all joins allocate at least the minimum size, so use caution in setting this variable to a large value globally. It is better to keep the global setting small and change to a larger setting only in sessions that are doing large joins. Memory allocation time can cause substantial performance drops if the global size is larger than needed by most queries that use it.
将缓冲区设置为大于保存每个匹配行所需的大小没有任何好处,并且所有连接至少分配最小大小,因此在将此变量全局设置为大值时要小心。最好保持全局设置较小,仅在进行大型连接的会话中更改为较大的设置。如果全局大小大于使用它的大多数查询所需的内存分配时间,则可能会导致性能大幅下降。