1、查询每个会话占用内存量
with t1 as (select sessid, sum(totalsize) totalsize, sum(usedsize) usedsize from gs_session_memory_detail group by 1) select a.sessionid, a.datname, a.usename, a.application_name, a.client_addr, pg_size_pretty(totalsize) total_size, pg_size_pretty(usedsize) used_size, a.query from pg_stat_activity a, t1 where a.sessionid = split_part(sessid,'.',2) order by usedsize desc;
2、查询每个会话占用内存详情
select pg_size_pretty(totalsize) totalsize,pg_size_pretty(usedsize) usedsize,datname,usename, contextname ,query from dbe_perf.session_memory_detail smd,pg_stat_activity sa where split_part(smd.sessid,'.','2')=sa.sessionid order by usedsize desc limit 10;