Bug #41599 FLUSH TABLE T should NOT flush entire query cache
Submitted: 18 Dec 2008 19:08 Modified: 7 Jul 2017 9:44
Reporter: Valeriy Kravchuk Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Query Cache Severity:S4 (Feature request)
Version:5.0, 5.1, 6.0 OS:Any
Assigned to: CPU Architecture:Any

[18 Dec 2008 19:08] Valeriy Kravchuk
Description:
FLUSH TABLE T flushes entire query cache if T exists and even if T does NOT exist. See bug #40809 and http://dev.mysql.com/doc/refman/5.0/en/flush.html. 

This may have serious performance impact. So, please, flush query cache only for tables listed explicitely, if they exist.

How to repeat:
mysql> show global status like 'qcache%';
+-------------------------+---------+
| Variable_name           | Value   |
+-------------------------+---------+
| Qcache_free_blocks      | 1       |
| Qcache_free_memory      | 8376576 |
| Qcache_hits             | 3       |
| Qcache_inserts          | 5       |
| Qcache_lowmem_prunes    | 0       |
| Qcache_not_cached       | 13      |
| Qcache_queries_in_cache | 2       |
| Qcache_total_blocks     | 7       |
+-------------------------+---------+
8 rows in set (0.00 sec)

mysql> flush table xxxxxxxnevereverexisted;
Query OK, 0 rows affected (0.01 sec)

mysql> show global status like 'qcache%';
+-------------------------+---------+
| Variable_name           | Value   |
+-------------------------+---------+
| Qcache_free_blocks      | 1       |
| Qcache_free_memory      | 8379648 |
| Qcache_hits             | 3       |
| Qcache_inserts          | 5       |
| Qcache_lowmem_prunes    | 0       |
| Qcache_not_cached       | 14      |
| Qcache_queries_in_cache | 0       |
| Qcache_total_blocks     | 1       |
+-------------------------+---------+
8 rows in set (0.00 sec)
[7 Jul 2017 9:44] Erlend Dahl
MySQL will no longer invest in the query cache, see:

http://mysqlserverteam.com/mysql-8-0-retiring-support-for-the-query-cache/