// mysql · memory

max_heap_table_size

Largest user-created MEMORY table.

デフォルト
16MB
Range
16KB to 2^64-1 bytes
Restart needed
いいえ
Default checked on
MySQL 8.4 LTS

何ができるか

Limits tables created with ENGINE=MEMORY. If internal temporary tables use the MEMORY engine (internal_tmp_mem_storage_engine=MEMORY), their limit is the smaller of this and tmp_table_size.

デフォルト値

16MB. 16777216 bytes (MySQL 8.4).

Check the current value

SHOW GLOBAL VARIABLES LIKE 'max_heap_table_size';

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

Change it

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

Only if you use MEMORY tables, or the MEMORY engine for internal temporary tables.

What can go wrong

A MEMORY table's size is fixed when it is created or altered; raising the setting does not grow existing tables.

Questions about max_heap_table_size

What is the default value of max_heap_table_size in MySQL?

16MB. 16777216 bytes (MySQL 8.4).

Does changing max_heap_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 max_heap_table_size?

Only if you use MEMORY tables, or the MEMORY engine for internal temporary tables.

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

// one client for every engine

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