msgbartop
A chronological documentation test project, nothing serious, really!
msgbarbottom

13 Sep 2008 Enable query caching in mysql

Posted by

Query caching is a way to increase the performance of mysql by caching database queries.
It’s quite easy to do and only requires to edit one file, in Debian it’s called /etc/mysql/my.cnf

Add the following lines in the mysqld section

[mysqld]
query-cache-type = 1
query-cache-size = 10M

restart the mysql daemon

# /etc/init.d/mysql restart

Verify that query caching is enabled

# mysql -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 33499
Server version: 5.0.32-Debian_7etch6-log Debian etch distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> SHOW VARIABLES LIKE '%query_cache%';
+------------------------------+----------+
| Variable_name                | Value    |
+------------------------------+----------+
| have_query_cache             | YES      |
| query_cache_limit            | 1048576  |
| query_cache_min_res_unit     | 4096     |
| query_cache_size             | 10485760 |
| query_cache_type             | ON       |
| query_cache_wlock_invalidate | OFF      |
+------------------------------+----------+
6 rows in set (0.00 sec)

If you see something like the out above, caching is enabled.

Tags: ,

Comments are closed.