MySQL has feature of logging all sql queries - General log.

But this log does not contain queries durations.

How to log all sql queries to analyze those durations?

  • The is some mysql-slow.log or similar, it logs the queries whose execution time was longer as a specific duration. You can configure this value. I can't remember the exact details, probably it is somewhere in my.cnf. Hopefully others will give you a full-featured answer.
    – peterh
    Aug 14, 2018 at 17:09

1 Answer 1


I got an answer after writing a question, but i want to share it to community.

Just set up Slow log and set SET GLOBAL long_query_time = 0.

You will see all sql queries with durations in slow log file.

  • And once you have done that, use pt-query-digest or mysqldumpslow -s t to discover the 'worst' queries and deal with them.
    – Rick James
    Aug 25, 2018 at 15:05

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.