MYSQL slow queries in the slow query log - but the same queries are executed very quickly manually

as header states, various queries appear in my database in the slow query log, but when I run them manually, they work 10 times faster.

for example, a relatively simple select query with several orders of parameters often takes up to 100 seconds in the log (yes, the table is very large) ... but when I run it myself in one database, it takes 2 seconds or so.

I studied server performance, and at that time, there seemed to be no particular slowdown or bottleneck, and many requests did not take much time during this period, but only one.

How can I start analyzing such a problem?

thanks for the help

+5
source share
1 answer

Your system may have been more busy when an abusive request entered a slow log.

A slow log may indicate that indexes are not fully used if value_strings are larger than the result set. Thus, runtime should be considered the key to the problem, but the row_examined query will give you a clearer answer.

Request time is a poor measure of performance on a server with a high load, because any request can be slow on a busy server. You must use EXPLAIN and SHOW PROFILE to profile your queries and improve them so that they do not put too much load on your server.

SELECT SQL_NO_CACHE ... , , , .

+5

All Articles