Does MySQL somehow save the last query (s)?

While working with MySQL and some really "greedy queries", I noticed that if I run such a greedy query, it may take 2 or 3 minutes to calculate. But if I repeat the request immediately after it is completed for the first time, it only takes a few seconds. Does MySQL save something like the "last x queries"?

+3
source share
3 answers

The short answer is yes. there is a request cache.

The query cache stores the text of the SELECT statement along with the corresponding result that was sent to the client. If an identical statement is received later, the server retrieves the results from the query cache, and does not parse and execute the statement again. The request cache is distributed between sessions, so a result set generated by one client can be sent in response to the same request issued by another client.

from here

+5
source

The request execution plan will be calculated and reused. Data can be cached, so subsequent executions will be faster.

0
source

Yes, depending on how the MySQL server is configured, it may use a query cache. This saves the results of identical queries until a certain limit is reached (which you can set if you are managing a server). Read http://dev.mysql.com/doc/refman/5.1/en/query-cache.html to learn more about how to configure the query cache to speed up your application if it issues a lot of identical queries.

0
source

All Articles