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 |
+-------------------------+----------+