Preventing queries caching in MySQL

后端 未结 3 817
一个人的身影
一个人的身影 2021-01-19 15:42

I\'m using the tomcat connection pool via JNDI resources.

In the context.xml:



        
3条回答
  •  情书的邮戳
    2021-01-19 16:12

    RESET QUERY CACHE only clears the query cache.

    FLUSH TABLES closes all tables (after flushing any unwritten data) and also clears the query cache.

    Clearing the cache cannot cause anything like the problem you are having. All it does is forcing subsequent queries to actually fetch the data from the tables (until these results are cached again).

    Please note, the query cache is guaranteed to never show outdated data. Any committed write to any table referred to by a query in the cache removes such query from the cache. If you see outdated data, then another external mechanism must be in action. For example, many ORM's do some row caching at some stage, and such mechanism may be broken, or may produce unexpected results if not used exactly as intended.

    And anyways, if either query_cache_size = 0 or query_cache_type = OFF (or 0), then the query cache is disabled.

提交回复
热议问题