Home > database >  Mysql query is slow for the first time, soon after problems, how to solve?
Mysql query is slow for the first time, soon after problems, how to solve?

Time:09-26

Use ali cloud servers, mysql5.7, single table data volume two million, each SQL for a period of time between the first query is slowly, after the query much faster, for example, some query, query for the first time in 30 s, 3 s, after the second
How to solve this problem?

CodePudding user response:

The second time the same SQL query because already cache results,

First 30 s is required, then use EXPLAIN a look at the execution plan, and then add the necessary index according to the circumstance or optimizing the query,

CodePudding user response:

That is the value of the first query is true SQL query efficiency? At the back of the query is obtained from the cache, so fast

CodePudding user response:

https://help.aliyun.com/knowledge_detail/41717.html

CodePudding user response:

The second query from the cache the query result set, so the efficiency is improved,

CodePudding user response:

Have a look at the explain plan of implementation, whether to have appropriate indexes,

CodePudding user response:

Upstairs said is right, the index partition, or change the query SQL there is always a suitable for you

CodePudding user response:

The innodb_buffer_pool_size configuration file size is how much, server memory is how much,

CodePudding user response:

The buffer pool size and see how many, slow query means that the data in a while and then LRU list was removed in buffer pool is not big enough, increase of dirty pages accounted,
And see if the query cache
  • Related