Percona toolkit find where load is coming from

I know the Percona toolkit has the option to analyze slow queries but can I use it to analyze and find what currently creates load on the MySQL?
Sometimes we get into a situation where MySQL is on 100% CPU but we can’t understand why from the process list. Sometimes it’s just a lot of very fast queries.
Can the Percona toolkit help me with that? Is it possible to understand what connection, user or query created what load on the MySql server?

PMM’s Query Analytics is best to analyze such spikes.

Thanks for the replay!
I read about PMM. Amazing tool.
|But I’m looking for something smaller.
Like running a tool that will output all the queries running for the past 5 minutes with time taken aggregated or something like that.

Does pt-query-digest can do the job? I’ll just sell slow-queries bigger than 0, meaning all. Will it know how to aggregate the same query and know even if a very short query that runs a lot of times takes most of the CPU?

Hi @Idan_Ahal,

If you want to log all the queries consider adjusting the long query time.
set global long_query_time=0 # or 0.1
Collect the log for the desired period, ensure performance / disk usage are acceptable.
You can rotate your slow log to easily parse them directly with the digest OR you can use the --since and --until options to parse required information.
The digest will not tell you what resource a query is using but you can get the stats for sure.

Thanks,
K

What do you mean by that?

Will it know … query that runs a lot of times takes most of the CPU?

No. It will just summarize the log for you.

But if a query runs for 0.001 seconds, for millions of times than the total run of this query will be very big, which means it makes most of the load.
Am I missing something?