云服务器内容精选

  • pgxc_stat_single_table(schema, tablename) 描述:在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)
  • gs_control_group_info(pool text) 描述:查看资源池关联的控制组信息 返回值类型:record 返回信息如下: 表4 gs_control_group_info(pool text)返回字段 属性 属性值 描述 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核心数。
  • GS_ALL_NODEGROUP_CONTROL_GROUP_INFO(text) 描述:提供了所有逻辑集群的控制组信息。该函数在调用的时候需要指定要查询逻辑集群的名称。例如要查询'installation'逻辑集群的控制组信息: 1 SELECT * FROM GS_ALL_NODEGROUP_CONTROL_GROUP_INFO('installation') 返回值类型:record 函数返回字段如下: 表3 GS_ALL_NODEGROUP_CONTROL_GROUP_INFO(text) 名称 类型 描述 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核的信息。
  • 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_history_instance_info(text, TIMESTAMP, TIMESTAMP, int default null) 描述:在CN节点上查询集群各节点历史资源使用情况,读取GS_WLM_INSTANCE_HISTORY系统表的数据。入参分别为:节点名称(可以输入ALL、C、D、实例名称),起始区间时间,结束区间时间,每个实例返回的最大数量。返回值为GS_WLM_INSTANCE_HISTORY。 返回值类型:setof record
  • pg_stat_get_tuple() 描述:在CN和DN上均可以执行,该函数仅8.1.3及以上集群版本支持。 函数无参时,查询CN上所有系统表的统计信息及表在每个CN上的脏页率,查询DN上所有系统表和用户表的统计信息和表在每个DN上的脏页率; 函数带入参时,入参是schema和表名,带入参的函数执行时查询单张表的统计信息和脏页率。 该函数的统计信息依赖于ANALYZE,为获取最准确的信息请先对表进行ANALYZE。 返回值类型:record 函数返回字段如下: 表1 pg_stat_get_tuple()返回字段 名称 类型 描述 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 记录表最后一次数据变化的时间。
  • pgxc_get_wlm_current_instance_info(text, int default null) 描述:在CN节点上查询集群各节点当前的资源使用情况,读取内存中还未存到GS_WLM_INSTANCE_HISTORY系统表的数据。入参分别为:节点名称(可以输入ALL、C、D、实例名称),每个节点返回的最大数量。返回值为GS_WLM_INSTANCE_HISTORY。 返回值类型:setof record
  • pg_stat_get_bgwriter_timed_checkpoints() 描述:后台写进程开启定时检查点的时间(因为checkpoint_timeout时间已经过期了)。 返回值类型:bigint pg_stat_get_bgwriter_requested_checkpoints() 描述:后台写进程开启基于后端请求的检查点的时间,因为已经超过了checkpoint_segments或因为已经执行了CHECKPOINT。 返回值类型:bigint
  • 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”。 如果该表正在进行由查询触发的analyze,则返回“Analyze in progress”。 如果该表是否需要analyze的状态未知,则返回“Unknown analyze status”。 返回值类型:text
  • pg_total_autovac_tuples(bool) 描述:返回total autovac相关的tuple记录,如nodename,nspname,relname以及各类tuple的IUD信息。 返回值类型:setof record pg_autovac_status(oid) 描述:返回和autovac状态相关的参数信息,如nodename,nspname,relname,analyze,vacuum设置,analyze/vacuum阈值, analyze/vacuum tuple数等。 返回值类型:setof record
  • pg_user_iostat(text) 描述:该函数8.1.2版本中已废弃,为兼容历史版本功能保留该函数,当前版本查询无效。 返回值类型:record 表2 pg_user_iostat(text)返回字段 名称 类型 描述 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/drop partition在该表上最后一次操作的时间,PG_STAT_ALL_TABLES视图last_data_changed列的数据是通过该函数求值,在表数量很大的场景中,通过视图获取表数据最后修改时间的性能较差,建议直接使用该函数获取表数据的最后修改时间。 返回值类型:timestamptz
  • 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 | XLOG | 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_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)