Is it useful to turn on MySQL query cache for performance

Now the MySQL default query cache is disabled, as I remember long time ago, the hit rate of MySQL is quite high when running WordPress.

So I am thinking if enable it now will improve performance, anyone tried?

2 Answers
2

General speaking yes for read-only applications (until MySQL 5.7, it’s deprecated since version 8.0), it enables equal SELECTs to return data extremely fast if identical calls are already stored in cache. You should consider that:

  • Only exact same clauses can benefit from the cache engine (no spaces, no comments, no actual differences in WHERE expressions);
  • If you are updating often the table you will not benefit much of it, since the queries get invalidated, and the invalidation algorithms can also reduce performance, in some cases.

Excellent alternatives are:

  • External caching engines (i.e. Memecached or Redis, my favorite, https://redislabs.com/wp-content/uploads/2016/03/15-Reasons-Caching-is-best-with-Redis-RedisLabs-1.pdf)
  • ProxySQL (since MySQL 8.0) on which I have no experience. Read more https://mysqlserverteam.com/mysql-8-0-retiring-support-for-the-query-cache/

I think also if you combine those with a good web server like NGINX or Apache2 and an HTTP accelerator like Varnish you can fly.

As I know, these are also the best current practices but I might have ignored something, please share it in case.

Leave a Comment