M
M
Matsun2020-07-17 11:35:35
MySQL
Matsun, 2020-07-17 11:35:35

Why does a MYSQL query live so little in the cache?

I have a very long request, it takes about two seconds.

How is it happening.

I refresh the page for the first time - this request is loaded in 2 seconds.
I update the second time, the result is taken from the cache, and it is already running for 0.05-0.1 seconds.

After 5 minutes, nothing, absolutely nothing in the database changes. But when the page is refreshed, the request again takes 2 seconds.

How can I make the cache lifetime increase to several hours, or so that it is reset only when the specific table, to which the request was made, changes

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lazy @BojackHorseman MySQL, 2020-07-17
Tag

the muscle will overwrite the old values ​​when the cache is full.
increase the cache size or use third-party caching.
the muscle cache is deprecated and will soon be gone in the engine
, there are alternative approaches. for example, query optimization. so that there is no need for caching at all. More precisely, this is the main recipe.

R
Roman Mirilaczvili, 2020-07-17
@2ord

1. Optimize a long query.
2. Use caching in the application with the desired lifetime.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question