MySQL Variables read_rnd_buffer_size 数据库 参数变量解释及正确配置使用
本站中文解释
READ_RND_BUFFER_SIZE,中文称为“随机读取缓冲区大小”,用于MySQL中优化排序查询,控制MySQL在进行排序查询时分配的内存缓冲区大小,当排序需要在内存中进行时,这个参数将发挥重要作用。
可通过SQL语句进行设置
SET GLOBAL read_rnd_buffer_size = 256 * 1024;
或者,
永久在MySQL配置文件中设置:
read_rnd_buffer_size = 256K
官方英文解释
read_rnd_buffer_size
Command-Line Format | --read-rnd-buffer-size=# |
---|---|
System Variable | read_rnd_buffer_size |
Scope | Global, Session |
Dynamic | Yes |
Type | Integer |
Default Value | 262144 |
Minimum Value | 1 |
Maximum Value | 2147483647 |
Unit | bytes |
This variable is used for reads from MyISAM
tables, and, for any storage engine, for Multi-Range Read
optimization.
When reading rows from a MyISAM
table in
sorted order following a key-sorting operation, the rows are
read through this buffer to avoid disk seeks. See
Section 8.2.1.14, “ORDER BY Optimization”. Setting the variable
to a large value can improve ORDER BY
performance by a lot. However, this is a buffer allocated for
each client, so you should not set the global variable to a
large value. Instead, change the session variable only from
within those clients that need to run large queries.
For more information about memory use during different
operations, see Section 8.12.4.1, “How MySQL Uses Memory”. For information
about Multi-Range Read optimization, see
Section 8.2.1.10, “Multi-Range Read Optimization”.