Search code examples
mysqldatabase-performance

How can i get a list of queries and their execution count


I want to get a list of queries executed against my mysql instance, I also want to get list of executions counts for them and duration,

I can get these stats in something like datadog APM, but I would like to be able to run a query for them locally.

is there a table or schema I need to look at?


Solution

    1. Turn on the "general log" and have it write to a file.

    2. Wait a finite amount of time.

    3. Then use pt-query-digest to summarize the results.

    4. Turn off the general log before it fills up disk.

    The slowlog (with a small value in long_query_time) is more useful for finding naughty queries.