MariaDB Performance Optimization: Tuning the Table Open Cache in 10.3.13


Table Open Cache:

  • In MariaDB, the table_open_cache stores recently opened tables in memory.
  • When an application needs to access a table, MariaDB checks the cache first.
  • If the table is in the cache, it's faster to access than reading it from disk.

The Problem in MariaDB 10.3.13:

  • In older versions of MariaDB (like 5.6.7), the default value for table_open_cache was 400.
  • MariaDB 10.3.13 increased the default value to 2000.

This change might cause issues for some setups:

  • If your system doesn't have enough memory to hold 2000 tables, MariaDB performance can suffer.
  • Applications might see issues like slow queries or errors if they can't open the tables they need.


  • Check your MariaDB configuration and adjust the table_open_cache value if needed.
  • A lower value (closer to 400) might be better if your system has limited memory.
  • Monitor MariaDB performance to see if the cache size is causing problems.

Additional Notes:

  • There's no one-size-fits-all solution for table_open_cache. The optimal value depends on your specific workload and system resources.
  • If you're unsure about the best value, consult the MariaDB documentation or seek help from a database administrator.

Check Current Value:

You can check the current table_open_cache value using a MariaDB client like mysql. Here's an example:

mysql> SHOW GLOBAL VARIABLES LIKE 'table_open_cache';
| Variable_name    | Value |
| table_open_cache | 2000  |  // This might be different on your system

Adjust the Value (if needed):

You can modify the table_open_cache value in the MariaDB configuration file (usually named my.cnf). Here's an example:

# Other configuration options...

table_open_cache = 1000  // Adjust this value as needed

Important: After making changes to my.cnf, you'll need to restart the MariaDB service for the new settings to take effect.

  1. Dynamically adjust the cache size:
  • MariaDB offers dynamic table cache management through internal algorithms. You can enable this by setting the table_open_cache_instances variable in my.cnf. This allows MariaDB to automatically adjust the cache size based on workload.
  1. Monitor and fine-tune:

    • Use monitoring tools to track the table_open_cache hit rate (percentage of times tables are found in the cache). An ideal hit rate is between 80% and 90%. If it's consistently lower, increase the cache size. Conversely, if it's frequently above 90%, you might be able to reduce the cache size to free up memory for other applications.
  2. Utilize query optimization:

    • Optimizing queries can reduce the need for frequent table access, indirectly affecting the table_open_cache. Techniques like proper indexing and avoiding redundant joins can help.
  3. Consider alternative storage engines:

    • If your workload involves frequently changing data or a high number of small tables, explore alternative storage engines like Memory engine (memory-resident tables) or InnoDB with smaller cache settings. These might be better suited for specific use cases.

Remember, the best approach depends on your specific database setup and workload. It's often a combination of these methods that achieves optimal performance.


Troubleshooting "Docker Not Adding User To MariaDB With Dockerfile"

The Players:Docker: A platform for running applications in isolated containers.MariaDB: An open-source relational database management system...

Connecting to MariaDB in Python: Leveraging mysql.connector (Mostly Compatible)

Why mysql. connector (Mostly) Works with MariaDB:High Compatibility: MariaDB is designed as a drop-in replacement for MySQL...

Troubleshooting .sql Database Import Errors in MariaDB (Stored Procedure Issues)

Incorrect SQL syntax for MariaDB: MySQL and MariaDB are both relational database management systems, but there can be slight differences in their syntax...

Beyond Sorting: Exploring Options for Ordered Data Retrieval in MariaDB

Sorting results with SELECT:This is the most common approach. You can use the SELECT statement with the ORDER BY clause to sort the data retrieved from a table in ascending order...