select a.sessid, a.contextname, count(*) as count from gs_session_memory_detail a left join pg_stat_activity b on regexp_replace(sessid, '^[^.]*\.','') = b.sessionid where b.application_name like '%Driver Tests%' and a.contextname='CachedPlan' group by a.sessid, a.contextname order by 3 desc;
select a.sessid, a.contextname, count(*) as count from gs_session_memory_detail a left join pg_stat_activity b on regexp_replace(sessid, '^[^.]*\.','') = b.sessionid where b.application_name like '%Driver Tests%' and a.contextname='CachedPlan' group by a.sessid, a.contextname order by 3 desc;
select a.sessid, a.contextname, count(*) as count from gs_session_memory_detail a left join pg_stat_activity b on regexp_replace(sessid, '^[^.]*\.','') = b.sessionid where b.application_name like '%Driver Tests%' and a.contextname='CachedPlan' group by a.sessid, a.contextname order by 3 desc;
select a.sessid, a.contextname, count(*) as count from gs_session_memory_detail a left join pg_stat_activity b on regexp_replace(sessid, '^[^.]*\.','') = b.sessionid where b.application_name like '%Driver Tests%' and a.contextname='CachedPlan' group by a.sessid, a.contextname order by 3 desc;