Greenplum 调优--查看子节点SQL运行状态
Posted xibuhaohao
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Greenplum 调优--查看子节点SQL运行状态相关的知识,希望对你有一定的参考价值。
摘自《Greenplum企业应用实战》
重点:
使用gp_dist_random函数,将查询下发到每个Segement
创建查看子节点SQL运行状态视图
1)创建v_active_sql视图方便查看SQL
create view v_active_sql as
select pg_stat_activity.procpid,pg_stat_activity.sess_id,
pg_stat_activity.usename,pg_stat_activity.waiting as w ,
to_char(pg_stat_activity.query_start,‘yyyymmdd hh24:mi:ss‘::text) as query_start,
to_char(now()-pg_stat_activity.query_start,‘hh24:mi‘::text) as exec,
pg_stat_activity.current_query
from pg_stat_activity
where pg_stat_activity.current_query <> ‘<IDLE>‘::text
order by pg_stat_activity.datname,
to_char(pg_stat_activity.query_start,‘yyyymmdd hh24:mi:ss‘::text);
2)创建获取IP的函数
create or replace function public.hostip()
return text
as $$
import socket
return socket.gethostbyname(socket.gethostname())
$$ language plpythonu;
3)创建all_seg_sql函数
create view public.all_seg_sql
as
select hostip(),
current_setting(replace(‘port‘||current_query,current_query,‘‘)) as port,
current_setting(replace(‘gp_contentid‘||current_query,current_query,‘‘)) as content,*
from gp_dist_random(‘v_active_sql‘)
where current_query <> ‘<IDLE>‘;
以上是关于Greenplum 调优--查看子节点SQL运行状态的主要内容,如果未能解决你的问题,请参考以下文章