// mysql · connections

table_definition_cache

Number of table definitions cached.

Par défaut
2000 (autosized)
Range
400 to 524288
Restart needed
Non
Default checked on
MySQL 8.4 LTS

Ce que cela fait

Caches the parsed definition of each table, separate from open handles. Autosized at startup to MIN(400 + table_open_cache / 2, 2000).

Valeur par défaut

2000 (autosized). Autosized; with the default table_open_cache of 4000 it is 2000 (MySQL 8.4).

Check the current value

SHOW GLOBAL VARIABLES LIKE 'table_definition_cache';

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

Change it

SET GLOBAL table_definition_cache = 10000;    -- until the next restart
SET PERSIST table_definition_cache = 10000;   -- 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

Schemas with more tables than the cache holds; compare Opened_table_definitions over time.

What can go wrong

Low: a little memory per definition.

Questions about table_definition_cache

What is the default value of table_definition_cache in MySQL?

2000 (autosized). Autosized; with the default table_open_cache of 4000 it is 2000 (MySQL 8.4).

Does changing table_definition_cache 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 table_definition_cache?

Schemas with more tables than the cache holds; compare Opened_table_definitions over time.

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

// one client for every engine

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