Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qcache_hits always 0

On Centos 6.3 I'm trying to enable query caching on Mysql. I have enabled query caching

SHOW VARIABLES LIKE 'query_cache_size';
query_cache_size    52428800

SHOW VARIABLES LIKE 'query_cache_type';
query_cache_type    ON

When running a few simple select queries (select * from titles), the Qcache_hits always stays 0.

(I'm using these sample mysql database: https://launchpad.net/test-db/+download)

show status like "Qcache%";
Qcache_free_blocks  1
Qcache_free_memory  52419904
Qcache_hits 0
Qcache_inserts  0
Qcache_lowmem_prunes    0
Qcache_not_cached   50
Qcache_queries_in_cache 0
Qcache_total_blocks 1

I'm out of options figuring out what's wrong here. Does anyone have an idea what can be wrong?

like image 650
Jorre Avatar asked Feb 20 '26 14:02

Jorre


2 Answers

You probably missed the query_cache_limit option, which prevents resultsets larger than this from being cached.

You may also have a non-standard setting for query_cache_type.

like image 119
RandomSeed Avatar answered Feb 22 '26 07:02

RandomSeed


I just was looking for an answer to the same problem: nothing was going into the query cache. My database name did not contain a minus (-) but did instead contain a period (.). I dumped the database -- happily it's still small as it's only in development -- and restored it into a different database with no . in the name, and the query cache is working fine now.

like image 38
Steve Michel Avatar answered Feb 22 '26 06:02

Steve Michel