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