Query Cache in mysqlserver

Ref:MySQL® 5 Certification Study Guide
Ref:Hight Performance Mysql Server(2nd Edition)
Ref:http://dev.mysql.com/doc/refman/5.1/en/query-cache.html
Ref:http://www.mysqlperformanceblog.com/2006/07/27/mysql-query-cache/

How to find out if Query Cache is enabled:

mysql> SHOW VARIABLES LIKE 'have_query_cache';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| have_query_cache | YES   |
+------------------+-------+

How to enable Query Cache:

Edit my.cnf file and Add as bellow:
[mysqld]

query_cache_type = 1

 query_cache_size = 10M

query_cache_limit = 2M

Bellow Command will show the variables setting for your mysql server.

mysql> SHOW VARIABLES LIKE 'query_cache%';
+------------------------------+---------+
| Variable_name | Value |
+------------------------------+---------+
| query_cache_limit | 1048576 |
| query_cache_min_res_unit | 4096 |
| query_cache_size | 8388608 |
| query_cache_type | ON |
| query_cache_wlock_invalidate | OFF |
+------------------------------+---------+

query_cache_size is the size of the query cache in bytes. If the size is 0,the cache is disabled
even if query_cache_type is not OFF.

How to setup query cache in runtime :

Ref : http://dev.mysql.com/doc/refman/5.1/en/query-cache-configuration.html

Leave a Reply

*