principlesqlMinor
query_cache_type = 0 vs query_cache_type = 1
Viewed 0 times
query_cache_typestackoverflowprogramming
Problem
Recently, I moved from standard MySQL to
However, I can see that, by default, the generated settings for
The only thing I run on the server is a Wordpress blog. My questions are:
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:
- May I enable query cache?
- There are some Wordpress plugins that offer database cache. Is the result similar of enabling query cache?
Solution
For a Wordpress blog it should be fine to set
-
It invalidates very easily (any update on some table invalidates all queries related to said table)
-
It has a single mutex on which any incoming or outgoing query must go through.
The query cache was fine in the days where machines had one core, maybe two; it does not fare well with multiple cores and high concurrency, and it does not fare well with write intensive applications.
Your Wordpress blog is not likely to be write intensive: your writes are new posts, updates, comments... How many of these? You may not even counter them on a per-minute basis...
It would actually not be read intensive either. Hundreds of reads per day Thousands? That's nothing.
With regard plugins, that greatly depends on the plugin and on your deployment. Wordpress is written in PHP, and PHP might use such cache mechanisms as file system, memcached or APC. It should be typically "better" caching for the specific purpose it is oriented. That is, it will invalidate cached data based on real changes to relevant data -- not for irrelevant operations on some table. The programmers of the plugin would need to decide which pieces of data are important to cache, which are not, how invalidation works.
Again, in the scale of a blog, this is no big deal, and should not make a significant difference (of course there could always be some crazy plugin).
Bottom line: for your needs, anything goes and it does not matter much.
query_cache_type = 1. See, the major problems with the query cache are:-
It invalidates very easily (any update on some table invalidates all queries related to said table)
-
It has a single mutex on which any incoming or outgoing query must go through.
The query cache was fine in the days where machines had one core, maybe two; it does not fare well with multiple cores and high concurrency, and it does not fare well with write intensive applications.
Your Wordpress blog is not likely to be write intensive: your writes are new posts, updates, comments... How many of these? You may not even counter them on a per-minute basis...
It would actually not be read intensive either. Hundreds of reads per day Thousands? That's nothing.
With regard plugins, that greatly depends on the plugin and on your deployment. Wordpress is written in PHP, and PHP might use such cache mechanisms as file system, memcached or APC. It should be typically "better" caching for the specific purpose it is oriented. That is, it will invalidate cached data based on real changes to relevant data -- not for irrelevant operations on some table. The programmers of the plugin would need to decide which pieces of data are important to cache, which are not, how invalidation works.
Again, in the scale of a blog, this is no big deal, and should not make a significant difference (of course there could always be some crazy plugin).
Bottom line: for your needs, anything goes and it does not matter much.
Context
StackExchange Database Administrators Q#33214, answer score: 5
Revisions (0)
No revisions yet.