To make sure MySQL uses the query cache, there are a few variables you need to set in the configuration file . Usually its my.cnf or my.ini so check on your server with the shell command locate , in our case we are running on a CentOS 5.2  distro and to its my.cnf located in /etc so we opened it by using :   nano /etc/my.cnf

First, is the query_cache_type. There are three possible settings: 0 (for off, do not use), 1 (for on, cache queries) and 2 (on demand). To ensure it is always on, place:
query-cache-type = 1
in the configuration file.
The query_cache_type is set to ON now. However, there is one more to set, and that is the query_cache_size. If set to 0 (the default), the cache will be disabled. This variable determines the memory, in bytes, used for the query cache. For our purposes, we will set it to 20 MB:
query-cache-size = 20M
Hope that helped a little 🙂

And if you want to check out whats happening in the mySql cache just run this comand

mysql -e “SHOW STATUS LIKE ‘%qcache%’;”

Similar Posts