// mysql · connections

table_open_cache_instances

Number of shards the open tables cache is split into.

Standard
16
Range
1 to 64
Restart needed
Ja
Default checked on
MySQL 8.4 LTS

Was es bewirkt

The cache is partitioned into instances of table_open_cache / table_open_cache_instances each, and a session locks only its one instance for DML, which cuts contention on many-core servers. DDL still locks the whole cache, which is why heavy DDL is the workload that feels this setting.

Standardwert

16. 16 (MySQL 8.4); the manual recommends 8 or 16 on systems that routinely use 16 or more cores.

Check the current value

SHOW GLOBAL VARIABLES LIKE 'table_open_cache_instances';

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

Change it

SET PERSIST_ONLY table_open_cache_instances = 16;
-- then restart mysqld (or set it under [mysqld] in my.cnf)

Restart required: the variable is read-only at runtime (SET GLOBAL fails with error 1238). Stage it with SET PERSIST_ONLY or under [mysqld] in my.cnf.

When to change it

Rarely: 16 is right for most many-core servers. Drop to 1 only when very large triggers on many tables make the cache hold excessive memory.

What can go wrong

Raising it shrinks each instance instead of growing the cache, so it only spreads the same table_open_cache across more locks. Many large triggers multiply per-instance memory, which is the one case the manual names for lowering it.

Questions about table_open_cache_instances

What is the default value of table_open_cache_instances in MySQL?

16. 16 (MySQL 8.4); the manual recommends 8 or 16 on systems that routinely use 16 or more cores.

Does changing table_open_cache_instances require a restart?

Yes. Restart required: the variable is read-only at runtime (SET GLOBAL fails with error 1238). Stage it with SET PERSIST_ONLY or under [mysqld] in my.cnf.

When should I change table_open_cache_instances?

Rarely: 16 is right for most many-core servers. Drop to 1 only when very large triggers on many tables make the cache hold excessive memory.

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

// one client for every engine

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

Text und Daten auf dieser Seite: CC BY 4.0, Quelle: SQLly (sqlly.app). Code und SQL-Snippets: MIT. Lizenzdetails