MySQL Query Cache
From Version 4.0.1, MySQL server features a Query Cache. When in use, the query cache stores the text of a SELECT query together with the corresponding result that is sent to a client. If another identical query is received, the server can then retrieve the results from the query cache rather than parsing and executing the same query again.
The query cache is extremely useful in an environment where (some) tables don’t change very often and you have a lot of identical queries. This is a typical situation for many web servers that use a lot of dynamic content.
Following is some performance data for the query cache (we got this by running the MySQL benchmark suite on a Linux Alpha 2x500MHz with 2G of RAM and a 64M query cache):
If you want to disable the query cache code, set query_cache_size=0. By disabling the query cache code there is no noticeable overhead. (query cache can be excluded from code with help of configure option --without-query-cache)
If all of the queries you’re preforming are simple (such as selecting a row from a table with one row),but still differ so that the queries cannot be cached, the overhead for having the query cache active is 13%. This could be regarded as the worst-case scenario. However, in real life, queries are much more complicated than our simple example, so the overhead is normally significantly lower.
Searches after one row in a one-row table are 238% faster. This can be regarded as close to the minimum speedup to be expected for ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access