spqplugin_v2系统表及视图说明

  • pg_dist_node

    描述:系统表,存储集群中所有节点的信息

    列名

    类型

    描述

    nodeid

    integer

    节点唯一标识

    groupid

    integer

    唯一标识一组节点

    nodename

    text

    节点IP或域名
    nodeport

    integer

    节点端口
    noderack

    text

    当前版本不使用
    hasmetadata

    boolean

    是否有元数据,CN节点为true,DN节点为false
    isactive

    boolean

    该节点是否被使用
    nodecluster

    name

    该节点所属spq cluster的名字
    metadatasynced

    boolean

    元数据是否同步。CN节点为true,DN节点为fasle
    shouldhaveshards

    boolean

    是否可以存储分片数据。CN节点为false,DN节点为true

    示例:

    openGauss=# select * from pg_dist_node;
    nodeid | groupid | nodename  | nodeport | noderack | hasmetadata | isactive | noderole | nodecluster | metadatasynced | shouldhaveshards 
    --------+---------+-----------+----------+----------+-------------+----------+----------+-------------+----------------+------------------
         1 |       0 | 127.0.0.1 |    15432 | default  | t           | t        | primary  | default     | t              | f
         2 |       1 | 127.0.0.1 |    15532 | default  | f           | t        | primary  | default     | f              | t
         3 |       2 | 127.0.0.1 |    15632 | default  | f           | t        | primary  | default     | f              | t
    (3 rows)
    
  • pg_dist_partition

    描述:系统表,存储分布式表的定义

    列名

    类型

    描述

    logicalrelid

    regclass

    分布式表表名

    partmethod

    char

    当前版本唯一值为'h',代表hash分区

    partkey

    text

    分区列的信息
    colocationid

    integer

    当前版本不使用
    repmodel

    char

    当前版本不使用
    autoconverted

    boolean

    当前版本不使用

    示例:

    openGauss=# select * from pg_dist_partition;
    logicalrelid | partmethod |                                                        partkey                                                         | colocationid | repmodel | autoconverted 
    --------------+------------+------------------------------------------------------------------------------------------------------------------------+--------------+----------+---------------
    t1           | h          | {VAR :varno 1 :varattno 1 :vartype 23 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location -1} |            1 | s        | f
    (1 row)
    
  • pg_dist_shard

    描述:系统表,存储分布式表每个分片的信息

    列名

    类型

    描述

    logicalrelid

    regclass

    分布式表表名

    shardid

    bigint

    分片编号

    shardstorage

    char

    存储类型,当前仅支持't',即普通表
    shardminvalue

    text

    当前shard的hash分区的最小hash值
    shardmaxvalue

    text

    当前shard的hash分区的最大hash值

    示例:

    openGauss=# select * from pg_dist_shard;
     logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue 
    --------------+---------+--------------+---------------+---------------
     t1           |   62025 | t            | -2147483648   | -1073741825
     t1           |   62026 | t            | -1073741824   | -1
     t1           |   62027 | t            | 0             | 1073741823
     t1           |   62028 | t            | 1073741824    | 2147483647
    (4 rows)
    
  • pg_dist_placement

    描述:系统表,存储分布式表每个分片的位置信息

    列名

    类型

    描述

    placementid

    bigint

    自增唯一标识

    shardid

    bigint

    分片编号

    shardstate

    int

    分片状态
    shardlength

    bigint

    对于hash分区,恒为0
    groupid

    integer

    唯一标识一组节点

    示例:

    openGauss=# select * from pg_dist_placement;
     placementid | shardid | shardstate | shardlength | groupid 
    -------------+---------+------------+-------------+---------
               1 |   62025 |          1 |           0 |       1
               2 |   62026 |          1 |           0 |       2
               3 |   62027 |          1 |           0 |       1
               4 |   62028 |          1 |           0 |       2
    (4 rows)
    
  • spq_shards

    描述:视图,查看所有的分片信息

    列名

    类型

    描述

    table_name

    regclass

    表名
    shardid

    bigint

    分片编号

    shard_name

    text

    分片名

    table_type

    text

    表类型
    nodename

    text

    节点IP或域名
    nodeport

    integer

    节点端口
    shard_size

    bigint

    分片大小

    示例:

    openGauss=# select * from spq_shards;
     table_name | shardid | shard_name | table_type  | nodename  | nodeport | shard_size 
    ------------+---------+------------+-------------+-----------+----------+------------
     t1         |   62025 | t1_62025   | distributed | 127.0.0.1 |    15532 |       8192
     t1         |   62026 | t1_62026   | distributed | 127.0.0.1 |    15632 |       8192
     t1         |   62027 | t1_62027   | distributed | 127.0.0.1 |    15532 |          0
     t1         |   62028 | t1_62028   | distributed | 127.0.0.1 |    15632 |       8192
    (4 rows)
    
  • spq_tables

    描述:视图,查看所有分布式表信息

    列名

    类型

    描述

    table_name

    regclass

    表名
    table_type

    text

    表类型

    distribution_column

    text

    分片列

    table_size

    text

    表大小
    shard_count

    bigint

    分片数量
    table_owner

    name

    属主
    access_method

    name

    当前版本不使用

    示例:

    openGauss=# select * from spq_tables;
     table_name | table_type  | distribution_column | table_size | shard_count | table_owner | access_method 
    ------------+-------------+---------------------+------------+-------------+-------------+---------------
     t1         | distributed | a                   | 24 kB      |           4 | openGauss   | 
    (1 row)
    
意见反馈
编组 3备份
    openGauss 2025-09-25 07:42:18
    取消