3

How to disable caching queries' results for the current session in MySQL8?

The Documentation of system variables has lot of variables that regard to caching but most of them are deprecated and I could not find any to use for disabling a query caching.
I am interested in disabling caching for all statements following the disable command. Is there any way to do that?

1 Answer 1

6

The query cache was removed in MySQL 8.

You can try clearing buffers, as described here: how to clear/flush mysql innodb buffer pool?

However, there will be OS-level disk caching, and also hardware (HDD/SDD) caching. This makes a 2 order magnitude difference on what I'm personally testing at the moment. What you're proposing may not be possible.

I'd suggest using EXPLAIN queries and very carefully thinking about what indexes are used, how many rows are touched, whether it's creating temporary tables, and generally to think through the execution strategy MySQL will be having ot execute.

Once you believe you have fixed your performance issue, see how it performs on a cold boot.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes, probably what I'll do is to prepare a separate instance of a DB inside a docker container that I will restart before querying it. That's a fat ass workaround but seems to be the only solution that would get rid of buffering. Good that you pointed out the file system buffering, I'll keep that in mind.
MySQL 8.0 will not support query cache, and users upgrading will be encouraged to use either Server-side Query Rewrite or ProxySQL as a man-in-the-middle cache. Source

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.