(mysql.info.gz) Query Cache
Info Catalog
(mysql.info.gz) Multiple servers
(mysql.info.gz) MySQL Database Administration
5.11 The MySQL Query Cache
==========================
From version 4.0.1 on, 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 was sent to the client. If the identical
query is received later, the server retrieves the results from the
query cache rather than parsing and executing the 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 generate a lot of
dynamic pages based on database content.
* The query cache does not return stale data. When tables are
modified, any relevant entries in the query cache are flushed.
* The query cache does not work in an environment where you have
many `mysqld' servers updating the same `MyISAM' tables.
Some performance data for the query cache follow. These results were
generated by running the MySQL benchmark suite on a Linux Alpha 2 x
500MHz system with 2GB RAM and a 64MB query cache.
* If all the queries you're performing 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.
In real life, queries tend to be much more complicated, so the
overhead normally is significantly lower.
* Searches for a single row in a single-row table are 238% faster
with the query cache than without it. This can be regarded as
close to the minimum speedup to be expected for a query that is
cached.
To disable the query cache at server startup, set the
`query_cache_size' system variable to 0. By disabling the query cache
code, there is no noticeable overhead. Query cache capabilities can be
excluded from the server entirely by using the `--without-query-cache'
option to `configure' when compiling MySQL.
Menu
* Query Cache How How the Query Cache Operates
* Query Cache in SELECT Query Cache `SELECT' Options
* Query Cache Configuration Query Cache Configuration
* Query Cache Status and Maintenance Query Cache Status and Maintenance
Info Catalog
(mysql.info.gz) Multiple servers
(mysql.info.gz) MySQL Database Administration
automatically generated byinfo2html