MySQL query cache出现负面作用的情形

1. 写语句特别频繁的场景不适合使用query cache,  因为query cache会被不停地失效,导致cache miss, 使用query cache纯粹是浪费性能。因为query cache本身也有使用代价,执行语句前它要先查一下cache中有没有,如果没有,从表中查到值之后还要更新一下cache

2. query cache累积过多可能出问题。当表中数据修改时,所有相关的cache都要失效;在失效过程中,要访问cache的查询都会被阻塞(即使跟这张表没关系);如果cache很多,最终给人的感觉是数据库长时间对查询无响应。

3. innodb中的长事务可能会使query cache失效。只要事务中修改了这张表,yi 会导致这个表关联的query cache在事务结束前全局失效:不仅本事务中会cache miss, 其他事务中也会cache miss.

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.