Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

query cache doesn't work

Tags:

mysql

I have turned on query_cache, and allocated memory for it:

| query_cache_limit            | 1048576    |
| query_cache_min_res_unit     | 4096       |
| query_cache_size             | 16777216   |
| query_cache_type             | ON         |
| query_cache_wlock_invalidate | OFF        |

But queries are not cached:

| Qcache_free_blocks             | 1        |
| Qcache_free_memory             | 16768400 |
| Qcache_hits                    | 0        |
| Qcache_inserts                 | 0        |
| Qcache_lowmem_prunes           | 0        |
| Qcache_not_cached              | 163      |
| Qcache_queries_in_cache        | 0        |
| Qcache_total_blocks            | 1        |

I use Innodb as storage engine, without transactions. The sample query which is not cached:

select * from `feed-ts`.feeds where id < 10;

It returns just one row.

Any ideas?

like image 247
zerkms Avatar asked Feb 24 '23 05:02

zerkms


1 Answers

There's a bug in MySQL.

The query cache simply doesn't get used for queries on InnoDB tables that are in a database with a hyphenated name (like feed-ts).

"Renaming" your database seems to be the only solution for now.

like image 187
John Flatness Avatar answered Mar 05 '23 17:03

John Flatness