How to tell if the MySQL Query Cache is enabledHow to tell if the MySQL Query Cache is enabled

Posted August 12th, 2009 in MySql

The MySQL Query Cache enables query results to be cached so if the same query is run multiple times the second and subsequent times the query are run are amost instant. This short post shows how to tell if the MySQL Query Cache is enabled.

How to tell if the MySQL Query Cache is enabled

From the MySQL command line interface, phpMyAdmin or another MySQL interface, or from your own code, run the following query:

show variables like 'query_cache_size';

If the result is 0 like in the following example, then the query cache is not enabled:

| Variable_name    | Value |
| query_cache_size | 0     |

If the result is greater than zero then it is enabled. The following example shows a query cache that is 50MB in size:

| Variable_name    | Value    |
| query_cache_size | 52428800 |

How to enable the query cache

Refer to my "MySQL Query Cache" post which shows how to enable the MySQL Query Cache. It can be done without having to restart the MySQL server process.

Upcoming posts

My upcoming Wednesday MySQL posts will look at some other things that can be done with the MySQL Query Cache. Make sure to subscribe to my RSS feed (below or top right) or follow me on Twitter or Facebook (top right) so you don't miss out. The next post in this series looks at how to prevent a query from using MySQL's query cache.

Related posts:


blog comments powered by Disqus