DB:gpperfmon
1.根据时间段查询最消耗内存的top20
select rsgname,query_hash,count(*) cnt,sum(memory/1024/1024)
FROM gpmetrics.gpcc_queries_history
where ctime>'2023-06-09 08:00:00.000' and ctime<'2023-06-09 21:07:00.000'
group by rsgname,query_hash
order by sum(memory) desc limit 20;
2.衍变修改,把执行耗时也列为参考条件
SELECT username, db, "cost", tsubmit, tstart, tfinish,tfinish-tstart as 执行耗时,status,rsgname, query_text,
memory/1024/1024 as "memory GB"
FROM gpmetrics.gpcc_queries_history
where ctime>'2023-06-14 08:00:00.000' and ctime<'2023-06-14 09:00:00.000'
order by memory desc
limit 200;