greenplum基本知识及基础信息


 
1. 下午查看一下greenplum的对应关系, oid与文件属性

1. oid是一种特殊的数据类型, 在PG/GP中,oid都是自增的。 
2. 每一个表空间,表,索引, 数据文件,函数,约束都对应一个唯一标识的oid, oid是全局递增的。 
3. 1259是pg_class对应的oid,每一个postgresql都是如此。 
select oid, relname from pg_class where oid = 'pg_class'::regclass;


select attrelid::regclass, attname, b.relname
from pg_attribute a, pg_class b
where a.attrelid = b.oid
and b.relnamespace = 11
and atttypid = 26
and b.relstorage='h'
and attname = 'oid'
and b.relname not like '%index';

4.  查询schema信息。 
select * from pg_namespace where nspowner > 10


5. 节点的配置信息和文件空间信息, 如下2个表在pg_global表空间下,全局共用。 
    gp_segment_configuration; 
    pg_filespace_entry

select * from gp_segment_configuration;     
select * from pg_filespace_entry  order by fsedbid
    
    
6. 创建视图: 
create view public.v_gp_id
as
select 'Greenplum'::name as gpname
    , current_setting('gp_num_contents_in_cluster') as numsegments
    , current_setting('gp_dbid')
    , current_setting('gp_contentid') as content;
    
    
create or replace function public.hostname()
    return text
as $$
    import socket
    return socket.gethostname()
$$    language plpythonu;
    
    
7. 在主节点上,想获取子节点的信息, 需要使用gp_dist_random. 
select gp_segment_id, count(1) from gp_dist_random('pg_class') group by 1 order by 1; 


select hostname() from gp_dist_random('gp_id');

8. 查看fi_user是否有对order_share的select权限
select has_table_privilege('fi_user','dw_stage.order_share','select');


9. 同一个表在pg_attribute表的字段数会比使用\d dw_stage.order_send时得到的要多,因为有一些隐藏字段在使用\d命令时,是不显示的。
--查询表的oid
select oid, relacl, * 
from pg_class 
where relname = 'orders_send';


--查询表的字段信息数
select *
from pg_attribute
where attrelid in (1246871, 1257272)
order by attrelid

10. 表的分布键策略
select * from gp_distribution_policy;
--下表localoid中的oid从pg_class表中得到
select * from gp_distribution_policy
where localoid = 1246871 
或者使用如下方法:
select * from gp_distribution_policy where localoid = 'orders_send'::regclass;


11.分区表的约束,不要主表上创建策略,除非这个策略适用于所有子表。 
12.查询分区表的分区信息:
--从pg_class中查询到oid信息
select oid, relacl, * 
from pg_class 
where relname = 'fi_gp_sale_rtn_prod_basic';

--查询出pg_partition表中的oid信息;
select oid, * from pg_partition 
where parrelid = 3069750

--根据pg_partition表中的oid,到pg_partition_rule表中查询对应的分区信息。
select *
from pg_partition_rule
where paroid = 3073374
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值