更新时间:2023-10-17 GMT+08:00
分享

查看表所在节点

用户在建表时可以指定表如何在节点之间分布或者复制,详情请参考•DISTRIBUTEBY,分布方式介绍可参阅选择分布方式

用户在建表时也可设置“Node Group”来指定表所在的Group,详情请参考•TO{GROUPgroupname|...

用户还可以通过以下命令查看表所在实例。

  1. 查询表所在的schema。
    select t1.nspname,t2.relname from pg_namespace t1,pg_class t2 where t1.oid = t2.relnamespace and t2.relname = 'table1';

    上述命令中,“nspname”为schema的名称,“relname”为表、索引、视图等对象的名称,“oid”为行标识符,“relnamespace”为包含这个关系的名称空间的OID,“table1”为表名称。

  2. 查看表的relname和nodeoids。
    select t1.relname,t2.nodeoids from pg_class t1, pgxc_class t2, pg_namespace t3  where t1.relfilenode =  t2.pcrelid and t1.relnamespace=t3.oid and t1.relname = 'table1' and t3.nspname ='schema1';

    上述命令中,“nodeoids”为表分布的节点OID列表,“relfilenode”为这个关系在磁盘上的文件的名称,“pcrelid”为表的OID,“schema1”为1中查询出的该表所在schema。

  3. 根据查询到的表分布的节点,查询表所在实例。
    select * from pgxc_node where oid in (nodeoids1, nodeoids2, nodeoids3);

    上述命令中的“nodeoids1, nodeoids2, nodeoids3”为2中查询到的3个nodeoids,操作时以实际查询到的为准,各nodeoids间以“,”隔开。

分享:

    相关文档

    相关产品