select
query sql_text,
mnt,
max_mem_max,
sum_query_time,
mnt as executions,
avg_query_time,
avg_proc_time,
avg_wait_time,
max_query_time,
avg_backoff_time,
Cop_proc_addr,
digest,
(case
when avg_proc_time = 0 then
'point_get or commit'
when (avg_proc_time > avg_wait_time
and
avg_proc_time > avg_backoff_time) then
'coprocessor_process'
when (avg_backoff_time > avg_wait_time
and
avg_proc_time < avg_backoff_time) then
'backoff'
else
'coprocessor_wait'
end) as type
from
(
select
query ,
count(*) mnt,
max(mem_max) max_mem_max,
avg(query_time) avg_query_time,
avg(process_time) avg_proc_time,
avg(wait_time) avg_wait_time,
max(query_time) max_query_time,
sum(query_time) sum_query_time,
max(digest) digest,
max(Cop_proc_addr) Cop_proc_addr,
avg(backoff_time) avg_backoff_time
from
information_schema.cluster_slow_query
where
time >= '2024-01-17 00:00:00'
group by query ) t
order by
max_mem_max desc
limit 10;