HomeMySQL Page 5 - Advanced MySQL Database Administration
4.10.4 Query Cache Status and Maintenance - MySQL
If you need to administer MySQL, this article gets you off to a good start. In this section, we discuss running multiple MySQL servers on the same machine, and the MySQL Query cache. The final installment of a multi-part series, it is excerpted from chapter four of the book MySQL Administrator's Guide, written by Paul Dubois (Sams; ISBN: 0672326345).
Descriptions of each of these variables are given in Section 4.2.4, "Server Status Variables." Some uses for them are described here.
The total number of SELECT queries is equal to:
+ queries with errors found by parser
The Com_select value is equal to:
+ queries with errors found during columns/rights
The query cache uses variable-length blocks, so Qcache_total_blocks and Qcache_free_blocks may indicate query cache memory fragmentation. After FLUSH QUERY CACHE, only a single free block remains.
Every cached query requires a minimum of two blocks (one for the query text and one or more for the query results). Also, every table that is used by a query requires one block. However, if two or more queries use the same table, only one block needs to be allocated.
The information provided by the Qcache_lowmem_prunes status variable can help you tune the query cache size. It counts the number of queries that have been removed from the cache to free up memory for caching new queries. The query cache uses a least recently used (LRU) strategy to decide which queries to remove from the cache. Tuning information is given in Section 4.10.3, "Query Cache Configuration."