Oracle 5.0 Reference Manual page 727

Table of Contents

Advertisement

new query cache size is 0
mysql>
SET GLOBAL query_cache_size = 41984;
Query OK, 0 rows affected (0.00 sec)
mysql>
SHOW VARIABLES LIKE 'query_cache_size';
+------------------+-------+
| Variable_name
| Value |
+------------------+-------+
| query_cache_size | 41984 |
+------------------+-------+
For the query cache to actually be able to hold any query results, its size must be set larger:
mysql>
SET GLOBAL query_cache_size = 1000000;
Query OK, 0 rows affected (0.04 sec)
mysql>
SHOW VARIABLES LIKE 'query_cache_size';
+------------------+--------+
| Variable_name
| Value
+------------------+--------+
| query_cache_size | 999424 |
+------------------+--------+
1 row in set (0.00 sec)
The
query_cache_size
may therefore be different from the value that you assign.
If the query cache size is greater than 0, the
works. This variable can be set to the following values:
• A value of
or
prevents caching or retrieval of cached results.
0
OFF
• A value of
or
enables caching except of those statements that begin with
1
ON
SQL_NO_CACHE.
• A value of
or
2
DEMAND
SQL_CACHE.
Setting the
GLOBAL query_cache_type
that connect after the change is made. Individual clients can control cache behavior for their own
connection by setting the
disable use of the query cache for its own queries like this:
mysql>
SET SESSION query_cache_type = OFF;
If you set
query_cache_type
only the numeric values are permitted.
To control the maximum size of individual query results that can be cached, set the
query_cache_limit
When a query is to be cached, its result (the data sent to the client) is stored in the query cache
during result retrieval. Therefore the data usually is not handled in one big chunk. The query cache
allocates blocks for storing this data on demand, so when one block is filled, a new block is allocated.
Because memory allocation operation is costly (timewise), the query cache allocates blocks with a
minimum size given by the
is executed, the last result block is trimmed to the actual data size so that unused memory is freed.
Depending on the types of queries your server executes, you might find it helpful to tune the value of
query_cache_min_res_unit
• The default value of
query_cache_min_res_unit
cases.
• If you have a lot of queries with small results, the default block size may lead to memory
fragmentation, as indicated by a large number of free blocks. Fragmentation can force the query
The MySQL Query Cache
|
[485]
value is aligned to the nearest 1024 byte block. The value reported
query_cache_type
causes caching of only those statements that begin with
[485]
SESSION query_cache_type
[485]
at server startup (rather than at runtime with a
[484]
system variable. The default value is 1MB.
query_cache_min_res_unit
[484]:
707
[485]
value determines query cache behavior for all clients
[485]
value. For example, a client can
[484]
system variable. When a query
[484]
is 4KB. This should be adequate for most
variable influences how it
SELECT
SELECT
statement),
SET

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents