// mysql · memory

tmp_table_size

Largest in-memory internal temporary table before it converts to disk.

기본값
16MB
Range
1KB to 2^64-1 bytes
Restart needed
아니요
Default checked on
MySQL 8.4 LTS

기능

Internal temporary tables back GROUP BY, DISTINCT, UNION and derived tables. With the TempTable engine (the default), tmp_table_size limits each table (from 8.0.28) and temptable_max_ram limits all of them together.

기본값

16MB. 16777216 bytes (MySQL 8.4).

Check the current value

SHOW GLOBAL VARIABLES LIKE 'tmp_table_size';

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

Change it

SET SESSION tmp_table_size = 67108864;   -- this connection
SET GLOBAL tmp_table_size = 67108864;    -- new connections, until restart
SET PERSIST tmp_table_size = 67108864;   -- 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

When Created_tmp_disk_tables is a large share of Created_tmp_tables and the queries are ones you cannot rewrite.

What can go wrong

Per table, per connection: many concurrent large GROUP BY queries can use much more than the setting.

Questions about tmp_table_size

What is the default value of tmp_table_size in MySQL?

16MB. 16777216 bytes (MySQL 8.4).

Does changing tmp_table_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 tmp_table_size?

When Created_tmp_disk_tables is a large share of Created_tmp_tables and the queries are ones you cannot rewrite.

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

// one client for every engine

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