// mysql · connections

table_open_cache

Number of open table handles cached across all sessions.

默认
4000
Range
1 to 524288
Restart needed
否
Default checked on
MySQL 8.4 LTS

作用

Each session that uses a table needs its own handle. When Opened_tables grows steadily, handles are being closed and reopened.

默认值

4000. 4000 (MySQL 8.4).

Check the current value

SHOW GLOBAL VARIABLES LIKE 'table_open_cache';

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

Change it

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

Servers with thousands of tables or many concurrent connections touching many tables.

What can go wrong

Needs file descriptors; mysqld may raise or be limited by open_files_limit.

Questions about table_open_cache

What is the default value of table_open_cache in MySQL?

4000. 4000 (MySQL 8.4).

Does changing table_open_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_open_cache?

Servers with thousands of tables or many concurrent connections touching many tables.

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

// one client for every engine

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