华为云用户手册

  • uuid_generate_v1() 描述:生成一个UUID类型的序列号。 返回类型:UUID 示例: 1 2 3 4 5 SELECT uuid_generate_v1(); uuid_generate_v1 -------------------------------------- c71ceaca-a175-11e9-a920-797ff7000001 (1 row) uuid_generate_v1函数根据时间信息、集群节点编号和生成该序列的线程号生成UUID,该UUID在单个集群内是全局唯一的,但在多个集群间的时间信息、集群节点编号、线程号和时钟序列仍然存在同时相等的可能性,因此多个集群间生成的UUID仍然存在极低概率的重复风险。
  • uuid() 描述:生成一个UUID类型的序列号。此函数为MySQL兼容性函数,仅8.2.0及以上集群版本支持。 返回类型:UUID 示例: 1 2 3 4 5 SELECT uuid(); uuid ---------------------------------- 6327dc96-f0e7-0100-f2f2-6c9ff700fffe (1 row) uuid函数内部生成原理同uuid_generate_v1()函数,即根据时间信息、集群节点编号和生成该序列的线程号生成UUID,该UUID在单个集群内是全局唯一的,但在多个集群间的时间信息、集群节点编号、线程号和时钟序列仍然存在同时相等的可能性,因此多个集群间生成的UUID仍然存在极低概率的重复风险。
  • UUID函数应用示例 UUID全局唯一的特点,可以作为数据表生成主键,也可以作为数据表的分布列,uuid_generate_v1()作为数据表分布列的默认值时,通过Hash分布可以将数据均匀分布到各个DN上,防止数据倾斜。 UUID的显著优点就是全局唯一,不需要中心节点,单个节点独立生成。但是也存在缺点,UUID较INT占用更多的存储空间,索引效率低,生成的ID随机,没有递增的特性,所以辨识困难。因此,在应用中,要根据实际情况选择UUID还是Sequence作为数据表主键。 示例如下: INT类型作为分布列。 创建示例哈希表mytable01,int类型作为分布列,插入数据后,查询数据存在数据倾斜。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 CREATE TABLE mytable01(a INT, b INT) DISTRIBUTE BY hash(a); CREATE TABLE INSERT INTO mytable01 VALUES(1, 10); INSERT 0 1 INSERT INTO mytable01 VALUES(1, 10); INSERT 0 1 INSERT INTO mytable01 VALUES(1, 10); INSERT 0 1 INSERT INTO mytable01 VALUES(1, 10); INSERT 0 1 INSERT INTO mytable01 VALUES(1, 10); INSERT 0 1 SELECT * FROM mytable01; a | b ---+---- 1 | 10 1 | 10 1 | 10 1 | 10 1 | 10 (5 rows) SELECT table_skewness('mytable01'); table_skewness ------------------------------------- ("dn_6003_6004 ",5,100.000%) ("dn_6001_6002 ",0,0.000%) ("dn_6005_6006 ",0,0.000%) (3 rows) UUID类型作为分布列。 创建示例哈希表mytable02,UUID类型作为分布列,插入数据后,查询数据分布正常。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 CREATE TABLE mytable02 (id UUID default uuid_generate_v1(), a INT, b INT) DISTRIBUTE BY hash(id); CREATE TABLE INSERT INTO mytable02(a, b) VALUES(1, 10); INSERT 0 1 INSERT INTO mytable02(a, b) VALUES(1, 10); INSERT 0 1 INSERT INTO mytable02(a, b) VALUES(1, 10); INSERT 0 1 INSERT INTO mytable02(a, b) VALUES(1, 10); INSERT 0 1 INSERT INTO mytable02(a, b) VALUES(1, 10); INSERT 0 1 SELECT * FROM mytable02; id | a | b --------------------------------------+---+---- 63e45c14-cc74-0e00-e9aa-0a2c3fa0fffe | 1 | 10 63e45c1f-4d18-0700-e9ab-0a2c3fa0fffe | 1 | 10 63e45c26-f859-0b00-e9ad-0a2c3fa0fffe | 1 | 10 63e45c23-9e5d-0300-e9ac-0a2c3fa0fffe | 1 | 10 63e45c2a-5825-0600-e9ae-0a2c3fa0fffe | 1 | 10 (5 rows) SELECT table_skewness('mytable02'); table_skewness ------------------------------------ ("dn_6001_6002 ",3,60.000%) ("dn_6003_6004 ",2,40.000%) ("dn_6005_6006 ",0,0.000%) (3 rows)
  • pg_xlogdump (start_lsn, end_lsn) 描述:可以在CN或者DN上执行,根据起始和终止lsn解析xlog文件。该函数仅8.3.0及以上集群版本支持。 入参:start_lsn,表示设定的起始LSN号;end_lsn,表示设定的终止LSN号。无需保证起始LSN号是一条xlog的起始位置,会从起始LSN号后第一条有效的xlog开始解析。 返回值类型:record 返回信息如下: 字段名称 类型 含义 node_name text 节点名称。 start_lsn text 设定的起始LSN。 end_lsn text 设定的终止LSN。 startlsn text xlog起始lsn。 endlsn text xlog终止lsn。 prelsn text 前一条xlog起始lsn。 xid xid xlog事务id号。 datalen int4 xlog数据长度,单位为byte。 totallen int4 xlog长度,单位为byte。 type text xlog类型。 desc text xlog内容。 blkref text xlog关联的relfilenode。 由于不同xlog类型xlogdescribe字段的长度不一致,pg_xlogdump()函数会对该字段进行裁剪,仅保留前64个字节。 可以找到目标xlog后结合pg_xlog_display_one_lsn()函数查看完整xlog内容。 示例: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 SELECT * FROM pg_xlogdump('0/101EF70','0/101F590'); node_name | startlsn | endlsn | prelsn | xlog_tid | datalen | totallen | xlogtype | xlogdescribe | blkref -----------+-----------+-----------+-----------+----------+---------+----------+----------+-----------------------+---------------------------------------------- datanode1 | 0/101EF70 | 0/101EFC0 | 0/101EF18 | 6 | 2 | 80 | Btree | insert leaf: off 1 | blkrel #0: rel 1663/1/2674, fork main, blk 1 datanode1 | 0/101EFC0 | 0/101F018 | 0/101EF70 | 6 | 3 | 88 | Heap | insert: off 2 flags 0 | blkrel #0: rel 1663/1/2608, fork main, blk 0 datanode1 | 0/101F018 | 0/101F068 | 0/101EFC0 | 6 | 2 | 80 | Btree | insert leaf: off 1 | blkrel #0: rel 1663/1/2673, fork main, blk 1 datanode1 | 0/101F068 | 0/101F0B8 | 0/101F018 | 6 | 2 | 80 | Btree | insert leaf: off 2 | blkrel #0: rel 1663/1/2674, fork main, blk 1 datanode1 | 0/101F0B8 | 0/101F110 | 0/101F068 | 6 | 3 | 88 | Heap | insert: off 3 flags 0 | blkrel #0: rel 1663/1/2608, fork main, blk 0 datanode1 | 0/101F110 | 0/101F160 | 0/101F0B8 | 6 | 2 | 80 | Btree | insert leaf: off 1 | blkrel #0: rel 1663/1/2673, fork main, blk 1 datanode1 | 0/101F160 | 0/101F1B0 | 0/101F110 | 6 | 2 | 80 | Btree | insert leaf: off 3 | blkrel #0: rel 1663/1/2674, fork main, blk 1 datanode1 | 0/101F1B0 | 0/101F208 | 0/101F160 | 6 | 3 | 88 | Heap | insert: off 4 flags 0 | blkrel #0: rel 1663/1/2608, fork main, blk 0 datanode1 | 0/101F208 | 0/101F258 | 0/101F1B0 | 6 | 2 | 80 | Btree | insert leaf: off 1 | blkrel #0: rel 1663/1/2673, fork main, blk 1 datanode1 | 0/101F258 | 0/101F2A8 | 0/101F208 | 6 | 2 | 80 | Btree | insert leaf: off 4 | blkrel #0: rel 1663/1/2674, fork main, blk 1 datanode1 | 0/101F2A8 | 0/101F300 | 0/101F258 | 6 | 3 | 88 | Heap | insert: off 5 flags 0 | blkrel #0: rel 1663/1/2608, fork main, blk 0 datanode1 | 0/101F300 | 0/101F350 | 0/101F2A8 | 6 | 2 | 80 | Btree | insert leaf: off 1 | blkrel #0: rel 1663/1/2673, fork main, blk 1 datanode1 | 0/101F350 | 0/101F3A0 | 0/101F300 | 6 | 2 | 80 | Btree | insert leaf: off 5 | blkrel #0: rel 1663/1/2674, fork main, blk 1 datanode1 | 0/101F3A0 | 0/101F3F8 | 0/101F350 | 6 | 3 | 88 | Heap | insert: off 6 flags 0 | blkrel #0: rel 1663/1/2608, fork main, blk 0 datanode1 | 0/101F3F8 | 0/101F448 | 0/101F3A0 | 6 | 2 | 80 | Btree | insert leaf: off 1 | blkrel #0: rel 1663/1/2673, fork main, blk 1 datanode1 | 0/101F448 | 0/101F498 | 0/101F3F8 | 6 | 2 | 80 | Btree | insert leaf: off 5 | blkrel #0: rel 1663/1/2674, fork main, blk 1 datanode1 | 0/101F498 | 0/101F4F0 | 0/101F448 | 6 | 3 | 88 | Heap | insert: off 7 flags 0 | blkrel #0: rel 1663/1/2608, fork main, blk 0 datanode1 | 0/101F4F0 | 0/101F540 | 0/101F498 | 6 | 2 | 80 | Btree | insert leaf: off 1 | blkrel #0: rel 1663/1/2673, fork main, blk 1 datanode1 | 0/101F540 | 0/101F590 | 0/101F4F0 | 6 | 2 | 80 | Btree | insert leaf: off 6 | blkrel #0: rel 1663/1/2674, fork main, blk 1 (19 rows)
  • pg_xlogdump (xid) 描述:可以在CN或者DN上执行,根据事务id号解析xlog文件并过滤。该函数仅8.3.0及以上集群版本支持。 返回值类型:record 返回信息如下: 名称 类型 描述 node_name text 节点名称。 start_lsn text 设定的起始LSN。 end_lsn text 设定的终止LSN。 startlsn text xlog起始lsn。 endlsn text xlog终止lsn。 prelsn text 前一条xlog起始lsn。 xid xid xlog事务id号。 datalen int4 xlog数据长度,单位为byte。 totallen int4 xlog长度,单位为byte。。 type text xlog类型。 desc text xlog内容。 blkref text xlog关联的relfilenode。 由于不同xlog类型xlogdescribe字段的长度不一致,pg_xlogdump()函数会对该字段进行裁剪,仅保留前64个字节。 可以找到目标xlog后结合pg_xlog_display_one_lsn()函数查看完整xlog内容。 示例: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 SELECT * FROM pg_xlogdump(1); node_name | startlsn | endlsn | prelsn | xlog_tid | datalen | totallen | xlogtype | xlogdescribe | blkref -----------+-----------+-----------+-----------+----------+---------+----------+----------+----------------+--------------------------------------------- datanode1 | 0/10000A0 | 0/10020F0 | 0/1000028 | 1 | 0 | 8248 | X LOG | page hint | blkrel #0: rel 1663/1/1255, fork fsm, blk 2 datanode1 | 0/10020F0 | 0/1004140 | 0/10000A0 | 1 | 0 | 8248 | XLOG | page hint | blkrel #0: rel 1663/1/1247, fork fsm, blk 2 datanode1 | 0/1004140 | 0/1004168 | 0/10020F0 | 1 | 4 | 38 | XLOG | nextOid: 18192 | datanode1 | 0/1004168 | 0/10061B8 | 0/1004140 | 1 | 0 | 8248 | XLOG | page hint | blkrel #0: rel 1663/1/2616, fork fsm, blk 2 datanode1 | 0/10061B8 | 0/1008208 | 0/1004168 | 1 | 0 | 8248 | XLOG | page hint | blkrel #0: rel 1663/1/2602, fork fsm, blk 2 datanode1 | 0/1008208 | 0/100A258 | 0/10061B8 | 1 | 0 | 8248 | XLOG | page hint | blkrel #0: rel 1663/1/2603, fork fsm, blk 2 datanode1 | 0/100A258 | 0/100C2A8 | 0/1008208 | 1 | 0 | 8248 | XLOG | page hint | blkrel #0: rel 1663/1/2609, fork fsm, blk 2 datanode1 | 0/100C2A8 | 0/100E2F8 | 0/100A258 | 1 | 0 | 8248 | XLOG | page hint | blkrel #0: rel 1663/1/2605, fork fsm, blk 2 datanode1 | 0/100E2F8 | 0/1010348 | 0/100C2A8 | 1 | 0 | 8248 | XLOG | page hint | blkrel #0: rel 1663/1/1259, fork fsm, blk 2 datanode1 | 0/1010348 | 0/1012398 | 0/100E2F8 | 1 | 0 | 8248 | XLOG | page hint | blkrel #0: rel 1663/1/2610, fork fsm, blk 2 (10 rows)
  • pg_xlog_display_one_lsn(start_lsn) 描述:可以在CN或者DN上执行,根据起始LSN号完整解析当前位置的xlog。该函数仅8.3.0及以上集群版本支持。 入参:start_lsn,表示起始LSN。需要保证输入的起始LSN号是一条xlog的开始处。 返回值类型:record 返回信息如下: 名称 类型 描述 node_name text 当前实例名 start_lsn text 设定的起始LSN end_lsn text 设定的终止LSN startlsn text xlog起始lsn endlsn text xlog终止lsn prelsn text 前一条xlog起始lsn xid xid xlog事务id号 datalen int4 xlog数据长度,单位为byte。 totallen int4 xlog长度,单位为byte。 type text xlog类型 desc text xlog内容 blkref text xlog关联的relfilenode 示例: 1 2 3 4 5 6 7 8 SELECT * FROM pg_xlog_display_one_lsn('0/101CA00'); node_name | startlsn | endlsn | prelsn | xlog_tid | datalen | totallen | xlogtype | xlogdescribe | blkref -----------+-----------+-----------+-----------+----------+---------+----------+-------------+------------------------------------------------------------------------- ----------+-------- datanode1 | 0/101CA00 | 0/101CA78 | 0/101C3F8 | 5 | 80 | 114 | Transaction | commit: 2023-10-19 22:21:38.617092+08; csn:0; inval msgs: catcache 11 ca tcache 10 | (1 row)
  • pg_xlogdump (tablename) 描述:在CN或者DN上执行,根据表名解析xlog文件并过滤。该函数仅8.3.0及以上集群版本支持。 返回值类型:record 返回信息如下: 名称 类型 描述 node_name text 节点名称。 start_lsn text 设定的起始LSN。 end_lsn text 设定的终止LSN。 startlsn text xlog起始lsn。 endlsn text xlog终止lsn。 prelsn text 前一条xlog起始lsn。 xid xid xlog事务id号。 datalen int4 xlog数据长度,单位为byte。 totallen int4 xlog长度,单位为byte。 type text xlog类型。 desc text xlog内容。 blkref text xlog关联的relfilenode。 由于不同xlog类型xlogdescribe字段的长度不一致,pg_xlogdump()函数会对该字段进行裁剪,仅保留前64个字节。 可以找到目标xlog后结合pg_xlog_display_one_lsn()函数查看完整xlog内容。 示例: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 SELECT * FROM pg_xlogdump(pg_class); node_name | startlsn | endlsn | prelsn | xlog_tid | datalen | totallen | xlogtype | xlogdescribe | blkref -----------+-----------+-----------+-----------+----------+---------+----------+----------+-----------------+--------------------------------------------------- datanode1 | 0/2DFC660 | 0/2DFE1D0 | 0/2DFA610 | 0 | 2 | 7000 | Heap | inplace: off 17 | blkrel #0: rel 1663/16324/15920, fork main, blk 2 datanode1 | 0/2E02270 | 0/2E02D88 | 0/2E00220 | 0 | 2 | 2840 | Heap | inplace: off 2 | blkrel #0: rel 1663/16324/15920, fork main, blk 0 datanode1 | 0/2E06E60 | 0/2E06F68 | 0/2E06E28 | 0 | 2 | 264 | Heap | inplace: off 10 | blkrel #0: rel 1663/16324/15920, fork main, blk 0 datanode1 | 0/2E0FC08 | 0/2E0FD10 | 0/2E0EBB8 | 0 | 2 | 264 | Heap | inplace: off 13 | blkrel #0: rel 1663/16324/15920, fork main, blk 0 datanode1 | 0/2E12960 | 0/2E12A68 | 0/2E11960 | 0 | 2 | 264 | Heap | inplace: off 15 | blkrel #0: rel 1663/16324/15920, fork main, blk 0 datanode1 | 0/2E12C88 | 0/2E12D90 | 0/2E12B78 | 0 | 2 | 264 | Heap | inplace: off 17 | blkrel #0: rel 1663/16324/15920, fork main, blk 0 datanode1 | 0/2E13FF8 | 0/2E14118 | 0/2E13110 | 0 | 2 | 264 | Heap | inplace: off 18 | blkrel #0: rel 1663/16324/15920, fork main, blk 0 datanode1 | 0/2E169F8 | 0/2E185E0 | 0/2E169B0 | 0 | 2 | 7120 | Heap | inplace: off 1 | blkrel #0: rel 1663/16324/15920, fork main, blk 1 datanode1 | 0/2E188B8 | 0/2E189D0 | 0/2E185E0 | 0 | 2 | 280 | Heap | inplace: off 2 | blkrel #0: rel 1663/16324/15920, fork main, blk 1 datanode1 | 0/2E18BF8 | 0/2E18CE0 | 0/2E189D0 | 0 | 2 | 232 | Heap | inplace: off 28 | blkrel #0: rel 1663/16324/15920, fork main, blk 1 datanode1 | 0/2E18E80 | 0/2E18F88 | 0/2E18DC0 | 0 | 2 | 264 | Heap | inplace: off 4 | blkrel #0: rel 1663/16324/15920, fork main, blk 1 datanode1 | 0/2E19160 | 0/2E19268 | 0/2E19088 | 0 | 2 | 264 | Heap | inplace: off 5 | blkrel #0: rel 1663/16324/15920, fork main, blk 1 datanode1 | 0/2E19460 | 0/2E1B1D0 | 0/2E19388 | 0 | 2 | 7508 | Heap | inplace: off 16 | blkrel #0: rel 1663/16324/15920, fork main, blk 6 datanode1 | 0/2E1B1D0 | 0/2E1B2E8 | 0/2E19460 | 0 | 2 | 280 | Heap | inplace: off 18 | blkrel #0: rel 1663/16324/15920, fork main, blk 6 datanode1 | 0/2E1B2E8 | 0/2E1B3D0 | 0/2E1B1D0 | 0 | 2 | 232 | Heap | inplace: off 30 | blkrel #0: rel 1663/16324/15920, fork main, blk 1 (15 rows)
  • pgxc_get_wal_speed() 描述:在CN上执行,获取每一个DN实例的wal生成速率以及备DN receive、write、flush、redo速率。该函数仅8.3.0及以上集群版本支持。 返回值类型:record 返回信息如下: 名称 类型 描述 node_name text 节点名称。 pid bigint 线程pid号。 local_role text 当前节点role。 peer_role text 接收方role。 peer_state text 接收方状态。 state text 传输状态。 generate_speed bigint 主DNwal生成速率,单位为byte/s。 receive_speed bigint 备DN接受速率,单位为byte/s。 write_speed bigint 备DN write速率,单位为byte/s。 flush_speed bigint 备DN刷盘速率,单位为byte/s。 redo_speed bigint 备DN redo速率,单位为byte/s。 1 2 3 4 5 6 SELECT * FROM pgxc_get_wal_speed(); node_name | pid | local_role | peer_role | peer_state | state | generate_speed | receive_speed | write_speed | flush_speed | apply_speed -----------+-----------------+------------+-----------+------------+-----------+----------------+---------------+-------------+-------------+------------- datanode1 | 140240389260824 | Primary | Secondary | Normal | Streaming | 0 | 0 | 0 | 0 | 0 datanode1 | 140240389262192 | Primary | Standby | Normal | Streaming | 0 | 0 | 0 | 0 | 0 (2 rows)
  • pgxc_get_xlog_stats() 描述:在CN上执行,统计各个DN节点自开机到当前不同xlog类型数量。该函数仅8.3.0及以上集群版本支持。 返回值类型:record 返回信息如下: 名称 类型 描述 node_name text 节点名称。 rmgr_name text xlog主类型。 record_info text xlog info信息。 record_count bigint 数量信息。 count_pct text 数量占比。 record_size bigint record大小, 单位byte。 record_pct text record大小占比。 fpi_size bigint fpi(full page image)大小,单位byte。 fpi_pct text fpi大小占比。 combined_size bigint xlog总大小,单位byte。 combined_pct text xlog总大小占比。 该函数只统计DN节点最近一次启动以来,不同类型的xlog数量与大小。 该函数统计的xlog的大小未考虑到其写盘时的对齐问题,与实际xlog段文件大小存在部分误差。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 SELECT * FROM pgxc_get_xlog_stats(); node_name | rmgr_name | record_info | record_count | count_pct | record_size | record_pct | fpi_size | fpi_pct | combined_size | combined _pct -----------+-------------+-------------------------------+--------------+-----------+-------------+------------+----------+---------+---------------+--------- ----- datanode1 | XLOG | checkpoint: shutdown | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | XLOG | checkpoint: online | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | XLOG | xlog no-op | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | XLOG | nextOid | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | XLOG | xlog switch | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | XLOG | backup end | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | XLOG | parameter change | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | XLOG | restore point | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | XLOG | full page writes | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | XLOG | xlog recovery end | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | XLOG | page hint | 1 | 0.12% | 56 | 0.11% | 8192 | 17.92% | 8248 | 8.71% datanode1 | XLOG | xlog fpi | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Transaction | commit | 3 | 0.35% | 246 | 0.50% | 0 | 0.00% | 246 | 0.26% datanode1 | Transaction | prepare | 1 | 0.12% | 469 | 0.96% | 0 | 0.00% | 469 | 0.50% datanode1 | Transaction | abort | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Transaction | commit prepared | 1 | 0.12% | 106 | 0.22% | 0 | 0.00% | 106 | 0.11% datanode1 | Transaction | abort prepared | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Transaction | xid assignment xtop | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Transaction | commit compact | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Storage | file create | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Storage | file truncate | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Storage | vacuum clear file | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | CLOG | zero page | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | CLOG | truncate before | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Database | create db | 1 | 0.12% | 50 | 0.10% | 0 | 0.00% | 50 | 0.05% datanode1 | Database | drop db | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Tablespace | create tablespace | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Tablespace | drop tablespace | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Tablespace | relative create | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | MultiXact | zero offsets page | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | MultiXact | zero members page | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | MultiXact | create multixact | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | RelMap | update relmap | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Standby | AccessExclusive locks | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Standby | xlog running xacts | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Standby | release AccessExclusive locks | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Standby | xlog standby csn | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Heap2 | freeze | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Heap2 | clean | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Heap2 | page upgrade | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Heap2 | cleanup info | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Heap2 | visible | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Heap2 | multi-insert | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Heap2 | bcm | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Heap2 | logical newpage rel | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Heap2 | no repair page | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Heap2 | multi-insert(init) base xid | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Heap | insert | 280 | 32.67% | 15964 | 32.63% | 14314 | 31.31% | 30278 | 31.99% datanode1 | Heap | delete | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Heap | update | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Heap | base shift | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Heap | hot update | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Heap | new page | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Heap | lock type | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Heap | inplace | 2 | 0.23% | 116 | 0.24% | 8164 | 17.86% | 8280 | 8.75% datanode1 | Heap | init page | 2 | 0.23% | 130 | 0.27% | 92 | 0.20% | 222 | 0.23% datanode1 | Heap | insert(init) base xid | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Btree | insert leaf | 562 | 65.58% | 31484 | 64.35% | 13352 | 29.21% | 44836 | 47.37% datanode1 | Btree | insert upper | 1 | 0.12% | 72 | 0.15% | 148 | 0.32% | 220 | 0.23% datanode1 | Btree | insert meta | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Btree | split left | 1 | 0.12% | 78 | 0.16% | 744 | 1.63% | 822 | 0.87% datanode1 | Btree | split right | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Btree | split left root | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Btree | split right root | 1 | 0.12% | 78 | 0.16% | 672 | 1.47% | 750 | 0.79% datanode1 | Btree | delete | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Btree | delete page | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Btree | delete page meta | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Btree | lev | 1 | 0.12% | 78 | 0.16% | 40 | 0.09% | 118 | 0.12% datanode1 | Btree | delete page half | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Btree | vacuum | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Btree | reuse page | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Gin | Create index | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Gin | Create ptree | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Gin | Insert item | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Gin | Page split | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Gin | Vacuum page | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Gin | Delete page | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Gin | Update metapage | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Gin | Insert new list page | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Gin | Delete list pages | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Gin | Vacuum data leaf page | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Gist | page update | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Gist | page split | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Gist | Create index | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Gist | page delete | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Sequence | log | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | SPGist | create index | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | SPGist | add leaf to page | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | SPGist | move leafs | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | SPGist | add node | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | SPGist | prefix off | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | SPGist | picksplit | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | SPGist | vacuum leaf | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | SPGist | vacuum root | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | SPGist | newest XID | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Slot | create slot | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Slot | advance slot | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Slot | drop slot | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Slot | check slot | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Heap3 | new cid | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Heap3 | heap rewrite | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% datanode1 | Barrier | barrier | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% | 0 | 0.00% (102 rows)
  • gs_stack() 描述:获取CN或DN进程的堆栈信息,函数入参tid均需要通过视图进行获取,不支持lwtid。该函数仅8.2.1及以上集群版本支持。 gs_stack()提供了比gdb、gstack等命令更灵活的、更快速的堆栈获得手段。仅建议管理员用户在问题分析定位过程中使用,不建议作为日常的监控工具使用。 返回值字段: tid:线程id。 lwtid:轻量级线程id。 stack:tid或lwtid线程对应的堆栈信息。 gs_stack()函数有四种使用方式: 方式一:gs_stack(tid)函数入参值为0,表示打印gsql所连接的CN或DN进程内所有线程的堆栈。 可通过gsql连接CN或DN执行。 获取CN或DN进程内所有线程的运行堆栈,运行时间长,对正常业务运行有影响,不建议频繁使用。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 SELECT * FROM gs_stack(0); tid | lwtid | stack -----------------+-------+------------------------------------------------------------------------------------------------------------------------ 140186894757888 | 95275 | __poll + 0x2d + | | ServerLoop() + 0x457 + | | PmStartupThreads() + 0x151 + | | PostmasterMain(int, char**) + 0x22a + | | main + 0x250 + | | __libc_start_main + 0xf5 + | | 0xb8d2d7 + | | 140185903825152 | 95316 | __poll + 0x2d + | | GsWaiter::wait(void*, long) + 0x11a + | | GsWaiter::wait(void*, int, int, long) + 0x7e + | | SysLoggerMain() + 0x109 + | | SubPostmasterMain(tag_gs_thread_args*) + 0xc9f + | | MainStarterThreadFunc(void*) + 0x6a + | | ThreadStarterFunc(void*) + 0x66 + | | start_thread + 0xc5 + | | clone + 0x6d + | | 140185903825528 | 95317 | __poll + 0x2d + | | GsWaiter::wait(void*, long) + 0x11a + | | AlarmCheckerMain() + 0x21b + | | SubPostmasterMain(tag_gs_thread_args*) + 0xcc6 + | | MainStarterThreadFunc(void*) + 0x6a + | | ThreadStarterFunc(void*) + 0x66 + | | start_thread + 0xc5 + | | clone + 0x6d + | | 140185903825904 | 95320 | __poll + 0x2d + | | GsWaiter::wait(void*, long) + 0x11a + | | ReaperBackendMain() + 0x1ee + | | SubPostmasterMain(tag_gs_thread_args*) + 0xd6f + | | MainStarterThreadFunc(void*) + 0x6a + | | ThreadStarterFunc(void*) + 0x66 + | | start_thread + 0xc5 + | | clone + 0x6d + | | 140185903826656 | 95324 | __poll + 0x2d + | | GsWaiter::wait(void*, long) + 0x11a + | | CheckpointerMain() + 0x8bb + | | AuxiliaryThreadUnderPm(AuxProcType) + 0x210 + | | SubPostmasterMain(tag_gs_thread_args*) + 0x7e0 + | | MainStarterThreadFunc(void*) + 0x6a + | | ThreadStarterFunc(void*) + 0x66 + | | start_thread + 0xc5 + | | clone + 0x6d + | | 140185903827032 | 95325 | __poll + 0x2d + | | GsWaiter::wait(void*, long) + 0x11a + | | BackgroundWriterMain() + 0x541 + | | AuxiliaryThreadUnderPm(AuxProcType) + 0x210 + | | SubPostmasterMain(tag_gs_thread_args*) + 0x7e0 + | | MainStarterThreadFunc(void*) + 0x6a + | | ThreadStarterFunc(void*) + 0x66 + 方式二:gs_stack(tid)函数入参值为指定的tid,表示打印gsql所连接的CN或DN进程内tid线程的堆栈。 可通过gsql连接CN或DN执行。 tid必须为所连CN或DN进程上存在的线程tid,否正会报错“invalid thread id”。 tid需通过其他视图获取,不支持lwtid。 获取指定CN或DN进程内指定线程的运行堆栈,运行时间短,对正常业务运行无影响,推荐使用。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 SELECT * FROM gs_stack(140185903826656); tid | lwtid | stack -----------------+-------+------------------------------------------------ 140185903826656 | 95275 | __poll + 0x2d + | | GsWaiter::wait(void*, long) + 0x11a + | | CheckpointerMain() + 0x8bb + | | AuxiliaryThreadUnderPm(AuxProcType) + 0x210 + | | SubPostmasterMain(tag_gs_thread_args*) + 0x7e0+ | | MainStarterThreadFunc(void*) + 0x6a + | | ThreadStarterFunc(void*) + 0x66 + | | start_thread + 0xc5 + | | clone + 0x6d + | | (1 row) 方式三:gs_stack('nodename', 0)函数第一个参数值为nodename,第二个参数值为0,表示打印由nodename指定的进程内所有线程的堆栈。 底层实现使用了“execute direct on”,因此必须使用gsql连接CN上执行。 第一个参数nodename需用单引号包括。 获取指定CN或DN进程内所有线程的运行堆栈,运行时间长,对正常业务运行有影响,不建议频繁使用。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 SELECT * FROM gs_stack('datanode2', 0); tid | lwtid | stack -----------------+-------+------------------------------------------------------------------------------------------------------------------------ 140634541242112 | 95442 | do_futex_wait + 0x5f + | | __new_sem_wait_slow + 0x57 + | | sem_timedwait + 0x35 + | | tagBinarySemaphore::timed_wait(int) + 0x4f + | | AuxiliaryThreadMain(void*) + 0x6d + | | LibcommThreadRoutine(void*) + 0x41 + | | start_thread + 0xc5 + | | clone + 0x6d + | | 140634549634816 | 95438 | epoll_wait + 0x33 + | | LibcommEpollWait(int, int) + 0x38 + | | RecvDataThreadMain(void*) + 0x8e + | | LibcommThreadRoutine(void*) + 0x41 + | | start_thread + 0xc5 + | | clone + 0x6d + | | 140634558027520 | 95432 | epoll_wait + 0x33 + | | LibcommEpollWait(int, int) + 0x38 + | | RecvDataThreadMain(void*) + 0x8e + | | LibcommThreadRoutine(void*) + 0x41 + | | start_thread + 0xc5 + | | clone + 0x6d + | | 140634566420224 | 95430 | epoll_wait + 0x33 + | | LibcommEpollWait(int, int) + 0x38 + | | RecvDataThreadMain(void*) + 0x8e + | | LibcommThreadRoutine(void*) + 0x41 + | | start_thread + 0xc5 + | | clone + 0x6d + | | 140634589476608 | 95426 | epoll_wait + 0x33 + | | LibcommEpollWait(int, int) + 0x38 + | | RecvDataThreadMain(void*) + 0x8e + | | LibcommThreadRoutine(void*) + 0x41 + | | start_thread + 0xc5 + | | clone + 0x6d + | | 140634597869312 | 95424 | do_futex_wait + 0x5f + | | __new_sem_wait_slow + 0x57 + | | sem_timedwait + 0x35 + | | tagBinarySemaphore::timed_wait(int) + 0x4f + | | SendDataWait() + 0x58 + | | SendDataThreadMain(void*) + 0xe4 + | | LibcommThreadRoutine(void*) + 0x41 + | | start_thread + 0xc5 + | | clone + 0x6d + | | 140634606262016 | 95387 | do_futex_wait + 0x5f + | | __new_sem_wait_slow + 0x57 + | | sem_timedwait + 0x35 + | | tagBinarySemaphore::timed_wait(int) + 0x4f + | | SendDataWait() + 0x58 + | | SendDataThreadMain(void*) + 0xe4 + 方式四:gs_stack('nodename', 0)函数第一个参数值为nodename,第二个参数值为tid,表示打印由nodename指定的进程内tid线程的堆栈。 底层实现使用了“execute direct on”,因此必须gsql连接CN上执行。 第一个参数nodename需用单引号包括。 第二个参数必须是nodename指定进程内存在的线程,否则会报错“invalid thread id”。 tid需通过其他视图获取,不支持lwtid。 仅获取指定CN或DN进程内指定线程的运行堆栈,运行时间短,对正常业务运行无影响,推荐使用。 1 2 3 4 5 6 7 8 9 10 11 SELECT * FROM gs_stack('datanode2', 140634549634816); tid | lwtid | stack -----------------+-------+------------------------------------ 140634549634816 | 95438 | epoll_wait + 0x33 + | | LibcommEpollWait(int, int) + 0x38 + | | RecvDataThreadMain(void*) + 0x8e + | | LibcommThreadRoutine(void*) + 0x41+ | | start_thread + 0xc5 + | | clone + 0x6d + | | (1 row)
  • pg_stat_wal_write() 描述:在CN或者DN上执行,记录当前实例的线程信息,并统计wal日志和数据页导入量及速率,这里以CN为例。 该函数仅8.2.0及以上集群版本支持。 返回值类型:bigint 返回值字段: node_name:实例名。 application_name:应用名。 query_start:当前正在执行语句的起始时间。 datapage_write:当前query导入的数据页总量,单位为bytes。 datapage_write_speed:数据页导入速率,单位为bytes/s。 wal_write:当前query导入的wal日志总量,单位为bytes。 wal_write_speed:wal导入速率,单位为bytes/s。 total_datapage_write:当前线程产生数据页总量,单位为bytes。 total_wal_write:wal总量,单位为bytes。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 SELECT * FROM pg_stat_wal_write(); node_name | datid | pid | lwtid | usesysid | application_name | state | query_start | backend_start | query_id | datapage_write | datapage_write_speed | wal_write | wal_write_speed | total_datapage_write | total_wal_write --------------+-------+-----------------+-------+----------+--------------------+--------+-------------------------------+-------------------------------+-------------------+----------------+----------------------+-----------+-----------------+----------------------+----------------- coordinator1 | 15979 | 140234153498368 | 25353 | 10 | JobScheduler | active | | 2022-11-15 11:57:54.396347+08 | 0 | 0 | | 0 | 0 | 0 | 0 coordinator1 | 15979 | 140234132027136 | 25354 | 10 | StatCollector | idle | | | 0 | 0 | | 0 | 0 | 0 | 0 coordinator1 | 15979 | 140234090084096 | 25356 | 10 | WDRSnapshot | idle | 2022-11-15 11:57:54.388948+08 | 2022-11-15 11:57:54.403055+08 | 0 | 0 | 0 | 0 | 0 | 0 | 0 coordinator1 | 15979 | 140234027169536 | 25359 | 10 | workload | active | 2022-11-15 11:57:54.404836+08 | 2022-11-15 11:57:54.389259+08 | 72620543991404472 | 0 | 0 | 1722112 | 0 | 0 | 0 coordinator1 | 15979 | 140234004621056 | 25360 | 10 | CalculateSpaceInfo | active | 2022-11-15 11:57:54.405677+08 | 2022-11-15 11:57:54.389847+08 | 72620543991349266 | 0 | 0 | 191326 | 0 | 0 | 0 coordinator1 | 15979 | 140233987839744 | 25361 | 10 | WorkloadMonitor | active | 2022-11-15 11:57:54.406263+08 | 2022-11-15 11:57:54.390373+08 | 72620543991404418 | 0 | 0 | 1183741 | 0 | 0 | 0 coordinator1 | 15979 | 140233971058432 | 25362 | 10 | WLMArbiter | active | 2022-11-15 11:57:54.406367+08 | 2022-11-15 11:57:54.390947+08 | 0 | 0 | 0 | 0 | 0 | 0 | 0 coordinator1 | 15979 | 140233228666624 | 14415 | 10 | gsql | active | 2022-11-15 21:19:32.200305+08 | 2022-11-15 21:09:38.916931+08 | 72620543991404422 | 0 | 0 | 30872 | 1000 | 0 | 0 coordinator1 | 15979 | 140233172035328 | 15516 | 10 | gsql | active | 2022-11-15 21:19:49.7877+08 | 2022-11-15 21:10:13.447312+08 | 72620543991404485 | 0 | 0 | 0 | 0 | 0 | 0 coordinator1 | 0 | 140234245269248 | 25348 | 0 | Background writer | idle | | 2022-11-15 11:57:54.383651+08 | 0 | 0 | | 0 | 0 | 0 | 0 coordinator1 | 0 | 140234291410688 | 25347 | 0 | CheckPointer | idle | | 2022-11-15 11:57:54.383231+08 | 0 | 0 | | 0 | 0 | 0 | 0 coordinator1 | 0 | 140234228487936 | 25349 | 0 | Wal Writer | idle | | 2022-11-15 11:57:54.384069+08 | 0 | 0 | | 0 | 0 | 0 | 0 coordinator1 | 0 | 140234068584192 | 25357 | 0 | TwoPhase Cleaner | idle | | 2022-11-15 11:57:54.388332+08 | 0 | 0 | | 0 | 0 | 0 | 0 coordinator1 | 0 | 140234048657152 | 25358 | 0 | LWLock Monitor | idle | | 2022-11-15 11:57:54.389239+08 | 0 | 0 | | 0 | 0 | 0 | 0 coordinator1 | 0 | 140234194925312 | 25351 | 0 | CBM Writer | idle | | 2022-11-15 11:57:54.38506+08 | 0 | 0 | | 0 | 0 | 0 | 0 coordinator1 | 0 | 140234211706624 | 25350 | 0 | Tick service | idle | | 2022-11-15 11:57:54.384136+08 | 0 | 0 | | 0 | 0 | 0 | 0 (16 rows) 行存不带索引批量导入时,数据页copy导入会产生logical newpage相关的xlog日志,在xlog量大于默认值时同样会触发流控。
  • pgxc_stat_wal_write() 描述:在所有CN上执行,记录各个DN上与CN交互的线程信息,并统计wal日志和数据页导入量及速率。该函数仅8.2.0及以上集群版本支持。 返回值类型:bigint 返回值字段: node_name:实例名。 application_name:应用名。 query_start:当前正在执行语句的起始时间。 datapage_write:当前query导入的数据页总量,单位为bytes。 datapage_write_speed:数据页导入速率,单位为bytes/s。 wal_write:当前query导入的wal日志总量,单位为bytes。 wal_write_speed:wal导入速率,单位为bytes/s。 total_datapage_write:当前线程产生数据页总量,单位为bytes。 total_wal_write:wal总量,单位为bytes。 1 2 3 4 5 6 7 8 9 SELECT * FROM pgxc_stat_wal_write(); node_name | datid | pid | lwtid | usesysid | application_name | state | query_start | backend_start | query_id | datapage_write | datapage_write_speed | wal_write | wal_write_speed | total_datapage_write | total_wal_write -----------+-------+-----------------+-------+----------+------------------------+--------+-------------------------------+-------------------------------+-------------------+----------------+----------------------+-----------+-----------------+----------------------+----------------- datanode1 | 15979 | 140328473442048 | 12408 | 10 | CalculateSpaceInfo | active | 2022-11-15 10:39:45.00219+08 | 2022-11-15 10:39:45.000918+08 | 0 | 0 | 0 | 70697 | 0 | 0 | 0 datanode1 | 0 | 140328075503360 | 12510 | 10 | WalSender to Secondary | idle | | 2022-11-15 10:39:46.708557+08 | 0 | 0 | | 210 | 0 | 0 | 0 datanode1 | 15979 | 140327896741632 | 13612 | 10 | coordinator1 | active | 2022-11-15 10:46:32.832548+08 | 2022-11-15 10:40:20.117516+08 | 72620543991349940 | 586579968 | 17425000 | 11743056 | 348000 | 5337505792 | 107245825 datanode1 | 15979 | 140327583217408 | 13614 | 10 | coordinator1 | active | 2022-11-15 10:46:32.832548+08 | | 72620543991349940 | 0 | 0 | 0 | 0 | 0 | 0 datanode1 | 15979 | 140327485175552 | 27914 | 10 | coordinator1 | active | 2022-11-15 10:47:06.493584+08 | 2022-11-15 10:47:06.489062+08 | 72620543991350020 | 0 | 0 | 0 | 0 | 0 | 8675 (5 rows) 行存不带索引批量导入时,数据页copy导入会产生logical newpage相关的xlog日志,在xlog量大于默认值时同样会触发流控。
  • pg_stat_get_local_analyze_status(oid) 描述:指定表在当前节点上的是否需要analyze的状态,仅在CN端有意义。该函数仅8.1.2及以上版本支持。 如果该表的修改行数超过analyze的阈值(根据autovacuum_analyze_threshold + autovacuum_analyze_scale_factor * reltuples计算,其中reltuples是pg_class中记录的表的估算行数),则返回“Analyze needed”。 如果该表的修改行数不超过analyze的阈值,则返回“Analyze not needed”。 返回值类型:text
  • pgxc_stat_single_table(schema, talename) 描述:在CN上执行,入参为schema和表名。查询单张表在全库中的统计信息及该表在每个DN上的脏页率。 该函数仅8.1.3及以上集群版本支持。 该函数的统计信息依赖于ANALYZE,为获取该表最准确的信息请先对表进行ANALYZE。 返回值类型:record 返回值字段与函数pg_stat_get_tuple()相同。 1 2 3 4 5 6 7 8 SELECT * FROM pgxc_stat_single_table('public','t1'); nodename | tableid | partid | last_vacuum | last_autovacuum | last_analyze | last_autoanalyze | vacuum_count | autovacuum_count | analyze_count | autoanalyze_count | n_tup_ins | n_ tup_upd | n_tup_del | n_tup_hot_upd | n_tup_change | n_live_tup | n_dead_tup | dirty_rate | last_data_changed -----------+---------+--------+------------------------+------------------------+-------------------------------+------------------------+--------------+------------------+---------------+-------------------+-----------+--- --------+-----------+---------------+--------------+------------+------------+------------+------------------- datanode1 | 1270075 | | 2000-01-01 08:00:00+08 | 2000-01-01 08:00:00+08 | 2023-01-09 09:38:43.220876+08 | 2000-01-01 08:00:00+08 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | (1 row)
  • pgxc_get_wlm_session_info_bytime(text, timestamp without time zone, timestamp without time zone, int) 描述:PGXC_WLM_SESSION_INFO视图在统计数据量很大的场景中性能较差,建议使用该函数进行筛选查询。入参分别为:筛选时间列('start_time', 'finish_time'),起始区间时间,结束区间时间,每个CN返回的最大数量。返回值为GS_WLM_SESSION_HISTORY。 返回值类型:setof record
  • pgxc_get_wlm_current_instance_info(text, int default null) 描述:在CN节点上查询集群各节点当前的资源使用情况,读取内存中还未存到GS_WLM_INSTANCE_HISTORY系统表的数据。入参分别为:节点名称(可以输入ALL、C、D、实例名称),每个节点返回的最大数量。返回值为GS_WLM_INSTANCE_HISTORY。 返回值类型:setof record
  • pgxc_get_wlm_history_instance_info(text, TIMESTAMP, TIMESTAMP, int default null) 描述:在CN节点上查询集群各节点历史资源使用情况,读取GS_WLM_INSTANCE_HISTORY系统表的数据。入参分别为:节点名称(可以输入ALL、C、D、实例名称),起始区间时间,结束区间时间,每个实例返回的最大数量。返回值为GS_WLM_INSTANCE_HISTORY。 返回值类型:setof record
  • gs_all_nodegroup_control_group_info(text) 描述:提供了所有逻辑集群的控制组信息。该函数在调用的时候需要指定要查询逻辑集群的名称。例如要查询'installation'逻辑集群的控制组信息: 1 SELECT * FROM gs_all_nodegroup_control_group_info('installation'); 返回值类型:record 函数返回字段如下: 名称 类型 描述 name text 控制组的名称 type text 控制组的类型 gid bigint 控制组ID classgid bigint Workload所属Class的控制组ID class text Class控制组 workload text Workload控制组 shares bigint 控制组分配的CPU资源配额 limits bigint 控制组分配的CPU资源限额 wdlevel bigint Workload控制组层级 cpucores text 控制组使用的CPU核的信息
  • gs_control_group_info(pool text) 描述:查看资源池关联的控制组信息 返回值类型:record 返回信息如下: 属性 属性值 描述 name class_a:workload_a1 class和workload名称。 class class_a Class控制组名称。 workload workload_a1 Workload控制组名称。 type DEFWD 控制组类型(Top、CLASS、BAKWD、DEFWD、TSWD)。 gid 87 控制组ID。 shares 30 占父节点CPU资源的百分比。 limits 0 占父节点CPU核数的百分比。 rate 0 Timeshare中的分配比例。 cpucores 0-3 CPU核心数。
  • pg_user_iostat(text) 描述:该函数8.1.2版本中已废弃,当前版本查询无效。8.2.0及以上集群版本中可使用PGXC_TOTAL_USER_RESOURCE_INFO视图查询实例上用户实时资源消耗信息。 返回值类型:record 名称 类型 描述 userid oid 用户ID。 min_curr_iops int4 当前该用户io在各DN中的最小值。 max_curr_iops int4 当前该用户io在各DN中的最大值。 min_peak_iops int4 该用户io峰值中,各DN的最小值。 max_peak_iops int4 该用户io峰值中,各DN的最大值。 io_limits int4 用户指定的资源池所设置的io_limits。 io_priority text 该用户所设io_priority。
  • pg_stat_get_last_data_changed_time(oid) 描述:insert/update/delete, exchange/truncate/drop partition在该表上最后一次操作的时间,PG_STAT_ALL_TABLES视图last_data_changed列的数据是通过该函数求值,在表数量很大的场景中,通过视图获取表数据最后修改时间的性能较差,建议直接使用该函数获取表数据的最后修改时间。 返回值类型:timestamptz
  • pg_stat_get_tuple() 描述:在CN和DN上均可以执行,该函数仅8.1.3及以上集群版本支持。 函数无参时,查询CN上所有系统表的统计信息及表在每个CN上的脏页率,查询DN上所有系统表和用户表的统计信息和表在每个DN上的脏页率; 函数带入参时,入参是schema和表名,带入参的函数执行时查询单张表的统计信息和脏页率。 该函数的统计信息依赖于ANALYZE,为获取最准确的信息请先对表进行ANALYZE。 返回值类型:record 函数返回字段如下: 名称 类型 描述 nodename text 节点名。 tableid oid 表的OID。 partid oid 分区表的分区OID。 last_vacuum timestamp with time zone 最后一次手动vacuum时间。 last_autovacuum timestamp with time zone 最后一次autovacuum时间。 last_analyze timestamp with time zone 最后一次手动analyze时间。 last_autoanalyze timestamp with time zone 最后一次autoanalyze时间。 vacuum_count bigint vacuum次数。 autovacuum_count bigint autovacuum次数。 analyze_count bigint analyze次数。 autoanalyze_count bigint autoanalyze_count次数。 n_tup_ins bigint 插入的行数。 n_tup_upd bigint 更新的行数。 n_tup_del bigint 删除的行数。 n_tup_hot_upd bigint HOT更新的行数。 n_tup_change bigint analyze之后改变的行数。 n_live_tup bigint live行估计数。 n_dead_tup bigint dead行估计数。 dirty_rate bigint 单节点的脏页率(单CN或单DN级)。 last_data_changed timestamp with time zone 记录表最后一次数据变化的时间。
  • - 描述:减 示例: 1 2 3 4 5 6 7 8 9 10 SELECT inet '192.168.1.43' - 36 AS RESULT; result ------------- 192.168.1.7 (1 row) SELECT inet '192.168.1.43' - inet '192.168.1.19' AS RESULT; result -------- 24 (1 row)
  • 功能描述 RELEASE SAVEPOINT删除当前事务先前定义的保存点。 保存点删除后便无法再作为回滚点使用,除此之外没有其它用户可见的行为。删除保存点并不能撤销在保存点建立起来之后执行的命令的影响。要撤销那些命令可以使用ROLLBACK TO SAVEPOINT 。在不再需要的时候删除保存点可以令系统在事务结束之前提前回收一些资源。 RELEASE SAVEPOINT也删除所有在指定的保存点建立之后的所有保存点。
  • hll_union(hll, hll) 描述:把两个hll数据结构union成一个。 返回值类型:hll 示例: 1 2 3 4 5 SELECT hll_union(hll_add(hll_empty(), hll_hash_integer(1)), hll_add(hll_empty(), hll_hash_integer(2))); hll_union ------------------------------------------ \x128b7f8895a3f5af28cafeda0ce907e4355b60 (1 row)
  • hll_print(hll) 描述:打印hll的一些debug参数信息。 返回值类型:cstring 示例: 1 2 3 4 5 SELECT hll_print(hll_empty()); hll_print ----------------------------------------------------------- EMPTY, nregs=2048, nbits=5, expthresh=-1(160), sparseon=1gongne (1 row)
  • hll_add_rev(hll_hashval, hll) 描述:把hll_hashval加入到hll中,和hll_add功能一样,只是参数位置进行了交换。 返回值类型:hll 示例: 1 2 3 4 5 SELECT hll_add_rev(hll_hash_integer(1), hll_empty()); hll_add_rev -------------------------- \x128b7f8895a3f5af28cafe (1 row)
  • hll_empty(int32 log2m, int32 regwidth, int64 expthresh) 描述:创建空的hll并依次指定参数log2m、regwidth、expthresh。expthresh取值范围是-1到7之间的整数。该参数可以用来设置从Explicit模式到Sparse模式的阈值大小。-1表示自动模式,0表示跳过Explicit模式,取1-7表示在基数到达2expthresh时切换模式。 返回值类型:hll 示例: 1 2 3 4 5 SELECT hll_empty(10, 4, 7); hll_empty ----------- \x116a48 (1 row)
  • hll_empty(int32 log2m, int32 regwidth, int64 expthresh, int32 sparseon) 描述:创建空的hll并依次指定参数log2m、regwidth、expthresh、sparseon。sparseon取0或者1。 返回值类型:hll 示例: 1 2 3 4 5 SELECT hll_empty(10,4,7,0); hll_empty ----------- \x116a08 (1 row)
  • hll_add(hll, hll_hashval) 描述:把hll_hashval加入到hll中。 返回值类型:hll 示例: 1 2 3 4 5 SELECT hll_add(hll_empty(), hll_hash_integer(1)); hll_add -------------------------- \x128b7f8895a3f5af28cafe (1 row)
共100000条