read_rnd_buffer_size
Buffer for reading rows in sorted order and for Multi-Range Read.
- 預設
256KB- Range
- 1 to 2147483647 bytes
- Restart needed
- 否
- Default checked on
- MySQL 8.4 LTS
其作用
When rows of a MyISAM table are read back in sorted order after a key sort, they go through this buffer to avoid disk seeks. It also drives Multi-Range Read (MRR) for any storage engine, which batches row lookups from a range scan into sequential reads. Most InnoDB OLTP queries use neither path, which is why the global default stays small.
預設值
256KB. 262144 bytes (MySQL 8.4).
Check the current value
SHOW GLOBAL VARIABLES LIKE 'read_rnd_buffer_size'; SELECT VARIABLE_NAME, VARIABLE_SOURCE, MIN_VALUE, MAX_VALUE, SET_TIME FROM performance_schema.variables_info WHERE VARIABLE_NAME = 'read_rnd_buffer_size';
Change it
SET SESSION read_rnd_buffer_size = 1048576; -- this connection SET GLOBAL read_rnd_buffer_size = 1048576; -- new connections, until restart SET PERSIST read_rnd_buffer_size = 1048576; -- new connections, and after restarts
No restart. SET GLOBAL (or SET PERSIST, which also survives restarts) applies to connections opened afterwards; existing connections keep their session value unless they SET it themselves.
When to change it
Per session, when a query plan shows Multi-Range Read or a large sorted MyISAM read and the bigger buffer measurably speeds it up.
What can go wrong
The buffer is allocated per client, so a large global value multiplies across connections even though only the few queries that use MRR or sorted MyISAM reads ever allocate it. Keep the global default and raise the session value where it helps.
Questions about read_rnd_buffer_size
What is the default value of read_rnd_buffer_size in MySQL?
256KB. 262144 bytes (MySQL 8.4).
Does changing read_rnd_buffer_size require a restart?
No. No restart. SET GLOBAL (or SET PERSIST, which also survives restarts) applies to connections opened afterwards; existing connections keep their session value unless they SET it themselves.
When should I change read_rnd_buffer_size?
Per session, when a query plan shows Multi-Range Read or a large sorted MyISAM read and the bigger buffer measurably speeds it up.
Back to all MySQL settings, or check the MySQL manual for every option.
Check read_rnd_buffer_size on your own server
SQLly runs the query above against MySQL and the other engines in this reference, from one desktop app on macOS, Windows and Linux.
本頁文字與資料: CC BY 4.0,請註明出處 SQLly (sqlly.app)。 程式碼與 SQL 片段: MIT. 授權詳情