MySQL Query Cache

MySQL query cache is good to cache select queries and their results and improve some performance of your database applications. So I thought I should write a quick tutorial to quickly set it up without going into the details. So here is what you have to do to enable it.

If you want to enable query cache without restarting the MySQL server then just run the following command on MySQL prompt/client:

set global query_cache_size=67108864;

This will set the cache size to around 64MB and also enable it. You can set it to any value you desire. You can then check the status later by running the following commands on MySQL prompt/client:

SHOW VARIABLES LIKE '%query_cache%';
SHOW STATUS LIKE '%qcache%';

These commands will show some useful information about the query cache like if it is enabled, how much memory is being used, how many queries are currently in the cache, and cache hit rate and a lot of other stuff.

This is really a quick way to enable query cache. For details see MySQL documentation