MySQL Query Caching
MySQL Query Caching
MySQL Query Cache Configuration
To Configure Query Cache
Check the variable have_query_cache, defaulty it has a value ‘YES’.
To check that by using following query.
SHOW VARIABLES LIKE ‘have_query_cache’;
When using a standard MySQL binary, this value is always YES,
even if query caching is disabled.
To Set the Size of Query Cache,
To set the size of the query cache, we set the query_cache_size variable.
if it sets to 0, then query cache is disable, default it is 0.
so the query cache is disabled by default.
To change its size by using following query.
SET GLOBAL query_cache_size = 41984;
When you set query_cache_size to a non-zero value, keep in mind
that the query cache needs a minimum size of about 40KB to allocate its
structures. (The exact size depends on system architecture.) If you set the
value too small, you’ll get a warning, as in this example:
mysql> SET GLOBAL query_cache_size = 41984;
here, we set 41 KB. 41*1024 = 41984bytes.
To check that
mysql> SHOW VARIABLES LIKE ‘query_cache_size’;
+——————+——-+
| Variable_name | Value |
+——————+——-+
| query_cache_size | 41984 |
+——————+——-+
The query_cache_size will be aligned to the nearest 1024 byte
block. The value reported may therefore be different from the value that you
set.
