MySQL Query Cache – How to Decide Whether to Enable Using InnoDB on Amazon RDS

amazon-rdsawsinnodbMySQL

How should the decision to enable / disable the MySQL query cache be made, on a server that uses just InnoDB tables. Say for example, if the cache is enabled, then how should the output of:

SHOW STATUS LIKE 'Qcache%';

be interpreted to make the decision? Or what other queries/profiling can be performed to get more information, and then how should those be interpreted? If it's to be enabled, how should its size be determined? I'm on Amazon RDS, using MySQL 5.6. I will end up being around ~250 separate databases totalling ~200gb in space.

Best Answer

SHOW GLOBAL STATUS;

Then compute these (whether using MyISAM or InnoDB):

  • Qcache_lowmem_prunes / Uptime -- How often the QC is being pruned -- More than 15/sec says there is a lot of overhead in having the QC on.
  • Qcache_not_cached / Uptime -- Cache attempts failed (per second). >40 is probably bad.
  • Qcache_not_cached / (Qcache_hits + Com_select + Qcache_not_cached) -- Percent of SELECTs that are not cached in the QC -- >30% means the QC is not very useful.
  • Qcache_hits / Qcache_inserts -- Hit to insert ratio -- > 10 is desirable