'Is there a way to see CPU usage for a specific clickhouse query

I'm testing a query and want to see how much CPU it will use.

I know I can use systems.query_log to get some useful info on query performance, but it does not have any info about CPU usage.

Is there a way to get CPU usage other than running top on my clickhouse server and watching the %CPU while I run my query?



Solution 1:[1]

It does have -- ProfileEvents: UserTimeMicroseconds + SystemTimeMicroseconds

select any(query), sum(`ProfileEvents.Values`[indexOf(`ProfileEvents.Names`, 'UserTimeMicroseconds')]) userCPU from system.query_log 
where type = 2 and event_date >= today()
group by normalizedQueryHash(query)
order by userCPU desc
limit 10

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Denny Crane