Bug #30629 SLEEP() disables query cache
Submitted: 24 Aug 2007 18:18 Modified: 6 Sep 2007 16:39
Reporter: Baron Schwartz (Basic Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.0 OS:Any
Assigned to: Paul DuBois CPU Architecture:Any

[24 Aug 2007 18:18] Baron Schwartz
Description:
The documentation at http://dev.mysql.com/doc/refman/5.0/en/query-cache-how.html doesn't say SLEEP() disables the query cache, but it appears to.

How to repeat:
mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> create table test(t int);
Query OK, 0 rows affected (0.04 sec)

mysql> insert into test(t) values(1);
Query OK, 1 row affected (0.15 sec)

mysql> reset query cache;
Query OK, 0 rows affected (0.00 sec)

mysql> show global status like 'qcache%';
+-------------------------+----------+
| Variable_name           | Value    |
+-------------------------+----------+
| Qcache_free_blocks      | 1        | 
| Qcache_free_memory      | 16759744 | 
| Qcache_hits             | 39       | 
| Qcache_inserts          | 267      | 
| Qcache_lowmem_prunes    | 0        | 
| Qcache_not_cached       | 196      | 
| Qcache_queries_in_cache | 0        | 
| Qcache_total_blocks     | 1        | 
+-------------------------+----------+
8 rows in set (0.00 sec)

mysql> show variables like 'query_cache%';
+------------------------------+----------------------+
| Variable_name                | Value                |
+------------------------------+----------------------+
| query_cache_limit            | 1048576              | 
| query_cache_min_res_unit     | 4096                 | 
| query_cache_size             | 16777216             | 
| query_cache_type             | ON                   | 
| query_cache_wlock_invalidate | OFF                  | 
+------------------------------+----------------------+
5 rows in set (0.00 sec)

mysql> select sleep(1) from test;
+----------+
| sleep(1) |
+----------+
|        0 | 
+----------+
1 row in set (1.01 sec)

mysql> show global status like 'qcache%';
+-------------------------+----------+
| Variable_name           | Value    |
+-------------------------+----------+
| Qcache_free_blocks      | 1        | 
| Qcache_free_memory      | 16759744 | 
| Qcache_hits             | 39       | 
| Qcache_inserts          | 267      | 
| Qcache_lowmem_prunes    | 0        | 
| Qcache_not_cached       | 199      | 
| Qcache_queries_in_cache | 0        | 
| Qcache_total_blocks     | 1        | 
+-------------------------+----------+
[24 Aug 2007 18:35] MySQL Verification Team
Thank you for the bug report.
[6 Sep 2007 16:39] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.

You are correct, SLEEP() makes queries uncachable.