Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

query_cache_type: enable or disable?

Recently, I moved from standard MySQL to Percona, and used the Percona Wizard to generate my.cnf.

However, I can see that, by default, the generated settings for my.cnf use query_cache_type = 0. (query cache is disabled).

The only thing I run on the server is a Wordpress blog. My questions are:

  1. May I enable query cache?
  2. There are some Wordpress plugins that offer database cache. Is the result similar of enabling query cache?
like image 648
bazaglia Avatar asked Jan 20 '13 00:01

bazaglia


People also ask

What is query_cache_type?

MySQL determines the queries to cache by examining the query_cache_type variable. Setting this value to 0 or OFF prevents caching or retrieval of cached queries. You can also set it to 1 to enable caching for all queries except for ones beginning with the SELECT SQL_NO_CACHE statement.

How do I enable query caching?

Open terminal and run the following command to open MySQL configuration file. We have enabled query cache by setting query_cache_type variable to 1, with individual query cache as 256Kb and total cache as 10Mb. You can change the values of query_cache_size and query_cache_limit as per your requirements.

How do I disable query cache?

Emptying and disabling the Query Cache FLUSH TABLES will have the same effect. Setting either query_cache_type or query_cache_size to 0 will disable the query cache, but to free up the most resources, set both to 0 when you wish to disable caching.


1 Answers

MySQL query cache is a cache mechanism that stores the text of the query (e.g. 'SELECT * FROM users WHERE deleted = 0') and the result of the query into memory. Please check this link to know how to enable mysql query cache in your server.

The wordpress DB cache plugins on the other hand, decreases count of queries to DB by caching queries in temp files (Check your cache directory wp-content/tmp/ for cache files).

Above two paragraphs prove that Wordpress db cache AND mysql query cache are different.

mysql query cache you should enable ONLY IF your site does more mysql reads than writes. since yours is a wordpress site, YES you can try by enabling mysql query cache.

Hope I answered your 2 questions.

like image 167
Jirilmon Avatar answered Oct 10 '22 21:10

Jirilmon