In MySQL, tables can be queried simultaneously. Tables are opened independently for each query. This increases memory usage but improves server performance.
Configuration of the table_open_cache variable prevents tables often queried by the same client, from having to be reopened. Table_open_cache is auto-sized on server startup. When the cache is at capacity and another table needs to be opened, MySQL will start by removing the least recently used table. When all space is currently being used by opened and in-use tables, new tables will still be opened, but as soon as a table becomes idle it will be removed from the cache until the set table_open_cache value is reached.
All tables open in the cache can be emptied with the flush-tables command.
Command Line table_open_cache variable configuration:
To configure table_open_cache in the command line, enter:
- - table-open-cache = #
Replace the bolded # with the best table cache value for your database.
Configuration File table_open_cache variable configuration:
You can also change the value of table_open_cache using a configuration file. To do so, you will use mysqld section. You will need to restart MySQL:
table-open-cache = #
Adjust the bolded # with the cache value that suits your database needs.