// mysql · temporary storage

temptable_max_ram

Total RAM the TempTable engine may use for internal temporary tables before spilling.

デフォルト
3% of RAM, 1GB to 4GB
Range
2MB to 2^64-1 bytes
Restart needed
いいえ
Default checked on
MySQL 8.4 LTS

何ができるか

Shared by every internal temporary table on the server. Beyond it, TempTable spills to memory-mapped files up to temptable_max_mmap, then to InnoDB on-disk tables. In 8.4 temptable_max_mmap defaults to 0, so spills go straight to InnoDB.

デフォルト値

3% of RAM, 1GB to 4GB. 3% of total memory, kept between 1GB and 4GB, since MySQL 8.4 (a fixed 1GB in 8.0). A server with less than about 33GB of RAM gets 1GB.

Check the current value

SHOW GLOBAL VARIABLES LIKE 'temptable_max_ram';

SELECT VARIABLE_NAME, VARIABLE_SOURCE, MIN_VALUE, MAX_VALUE, SET_TIME
FROM performance_schema.variables_info
WHERE VARIABLE_NAME = 'temptable_max_ram';

Change it

SET GLOBAL temptable_max_ram = 2147483648;    -- until the next restart
SET PERSIST temptable_max_ram = 2147483648;   -- now and after restarts

No restart. SET GLOBAL or SET PERSIST takes effect immediately; SET PERSIST also writes mysqld-auto.cnf so the value survives restarts.

When to change it

Raise it on reporting servers with heavy GROUP BY or window-function workloads that spill.

What can go wrong

Memory taken here is not available to the buffer pool.

Questions about temptable_max_ram

What is the default value of temptable_max_ram in MySQL?

3% of RAM, 1GB to 4GB. 3% of total memory, kept between 1GB and 4GB, since MySQL 8.4 (a fixed 1GB in 8.0). A server with less than about 33GB of RAM gets 1GB.

Does changing temptable_max_ram require a restart?

No. No restart. SET GLOBAL or SET PERSIST takes effect immediately; SET PERSIST also writes mysqld-auto.cnf so the value survives restarts.

When should I change temptable_max_ram?

Raise it on reporting servers with heavy GROUP BY or window-function workloads that spill.

Back to all MySQL settings, or check the MySQL manual for every option.

// one client for every engine

Check temptable_max_ram 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.