[维护集群案例集] GaussDB 查询用户空间使用情况
create table user_resource
(node_name text,
username name,
used_memory int,
total_memory int,
used_cpu float,
total_cpu int,
used_space bigint,
total_space bigint,
used_temp_space bigint,
total_temp_space bigint,
used_spill_space bigint,
total_spill_space bigint,
read_kbytes bigint,
write_kbytes bigint,
read_counts bigint,
write_counts bigint,
read_speed float,
write_speed float
);
create or replace function query_user()
RETURNS setof user_resource
AS $$
DECLARE
node_str text;
row record;
row_data record;
query_str text;
BEGIN
node_str := 'SELECT node_name FROM pgxc_node';
FOR row in execute(node_str) LOOP
query_str := 'EXECUTE DIRECT ON (' || row.node_name || ') ' || ''' SELECT node_name, pg_total_user_resource_info.* FROM pg_node_env,pg_total_user_resource_info ''' ;
FOR row_data IN EXECUTE(query_str) LOOP
return next row_data;
END LOOP;
END LOOP;
return;
END; $$
LANGUAGE 'plpgsql' NOT FENCED;
- 点赞
- 收藏
- 关注作者
评论(0)