GaussDB-统计信息函数(下)
-
remote_bgwriter_stat()
描述:显示整个集群所有实例的bgwriter线程刷页信息,候选buffer链中页面个数,buffer淘汰信息(本节点除外、DN上不可使用)。
返回值类型:record。
参数 类型 描述 node_name text 实例名称。 bgwr_actual_flush_total_num bigint 从启动到当前时间bgwriter线程总计刷脏页数量。 bgwr_last_flush_num integer bgwriter线程上一批刷脏页数量。 candidate_slots integer 当前候选buffer链中页面个数。 get_buffer_from_list bigint buffer淘汰从候选buffer链中获取页面的次数。 get_buf_clock_sweep bigint buffer淘汰从原淘汰方案中获取页面的次数。 示例:
remote_bgwriter_stat函数查询bgwriter线程刷页信息。
| ``` gaussdb=# SELECT * FROM remote_bgwriter_stat(); node_name | bgwr_actual_flush_total_num | bgwr_last_flush_num | candidate_slots | get_buffer_from_list | get_buf_clock_sweep -----------+-----------------------------+---------------------+-----------------+----------------------+--------------------- datanode3 | 0 | 0 | 266232 | 404 | 0 datanode2 | 0 | 0 | 266232 | 424 | 0 datanode1 | 0 | 0 | 266232 | 393 | 0 (3 rows)
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
-
gs_stack()
描述:显示线程调用栈。查询该函数需要有SYSADMIN权限或者MONADMIN权限。
参数:tid,线程id。tid是可选参数,指定tid参数时,函数返回tid对应线程调用栈;当不指定tid参数时,函数返回所有线程的调用栈。
返回值:当指定tid时,返回值为text;当不指定tid时,返回值为setof record。
示例:
获取指定线程调用栈。
| ``` gaussdb=# SELECT * FROM gs_stack(139663481165568); gs_stack -------------------------------------------------------------------- __poll + 0x2d + WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x29f + WaitLatch(Latch volatile*, int, long) + 0x2e + JobScheduleMain() + 0x90f + int GaussDbThreadMain<(knl_thread_role)9>(knl_thread_arg*) + 0x456+ InternalThreadFunc(void*) + 0x2d + ThreadStarterFunc(void*) + 0xa4 + start_thread + 0xc5 + clone + 0x6d + (1 row)
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 获取所有线程的调用栈。 | ``` gaussdb=# SELECT * FROM gs_stack(); -[ RECORD 1 ]------------------------------------------------------------------------------------------------------- tid | 139670364324352 lwtid | 308 stack | __poll + 0x2d | CommWaitPollParam::caller(int (*)(pollfd*, unsigned long, int), unsigned long) + 0x34 | int comm_socket_call<CommWaitPollParam, int (*)(pollfd*, unsigned long, int)>(CommWaitPollParam*, int (*)(pollfd*, unsigned long , int)) + 0x28 | comm_poll(pollfd*, unsigned long, int) + 0xb1 | ServerLoop() + 0x72b | PostmasterMain(int, char**) + 0x314e | main + 0x617 | __libc_start_main + 0xf5 | 0x55d38f8db3a7 [ RECORD 2 ]------------------------------------------------------------------------------------------------------- tid | 139664851859200 lwtid | 520 stack | __poll + 0x2d | WaitLatchOrSocket(Latch volatile*, int, int, long) + 0x29f | SysLoggerMain(int) + 0xc86 | int GaussDbThreadMain<(knl_thread_role)17>(knl_thread_arg*) + 0x45d | InternalThreadFunc(void*) + 0x2d | ThreadStarterFunc(void*) + 0xa4 | start_thread + 0xc5 | clone + 0x6d ``` | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -
gs_perf_start()
描述:调用perf_event_open,采集各个线程的调用栈及各函数运行时间。查询该函数需要有SYSADMIN权限或者MONADMIN权限。
参数说明如下:
参数名称 描述 类型 范围 duration 采集堆栈时长(单位为秒,如输入浮点型,会对浮点型小数点后第一位进行四舍五入后取整处理)。 integer 1~60 freq 采集堆栈频率(可选参数,单位为HZ,默认为100)。 integer 10~1000 返回值类型:text
示例:
设置频率为100HZ,采集10s堆栈信息。
| ``` gaussdb=# SELECT * FROM gs_perf_start(10, 100); gs_perf_start --------------------- Perf start succeed. (1 row)
| ----------------------------------------------------------------------------------------------------------------------------- |  gs_perf_start在采集过程中,需要申请环形buffer,该buffer的大小受操作系统中/proc/sys/kernel/perf_event_mlock_kb控制。如果采集过程出现”perf mmap failed”错误,可以通过调整/proc/sys/kernel/perf_event_mlock_kb的大小,再重新开始采集。 -
gs_perf_query()
描述:归并各个线程的函数调用栈并求和函数运行时间,显示聚集后的结果。查询该函数需要有SYSADMIN权限或者MONADMIN权限。
参数:nan
返回值类型:setof record。
函数返回字段说明:
名称 类型 描述 backtrace text 堆栈名称(带树状结构)。 period bigint 堆栈的执行时间。 level integer 堆栈所在堆栈调用树的层级。 sequence integer 堆栈调用树排序后的顺序。 thread_name text 该堆栈所在的线程名称。 overhead float 该堆栈执行所占时间百分比。 示例:
查询采集到的堆栈信息。
| ``` gaussdb=# SELECT * FROM gs_perf_query() WHERE overhead > 2 AND level < 10; backtrace | period | level | sequence | thread_name | overhead -------------------------------------------------------------------------------+-------------+-------+----------+---------------+---------- root +| 74140000000 | 0 | 1 | root | 100 | | | | | worker +| 69930000000 | 1 | 2 | worker | 94.32 | | | | | |── start_thread +| 67620000000 | 2 | 3 | worker | 91.21 | | | | | | └── ThreadStarterFunc +| 67620000000 | 3 | 4 | worker | 91.21 | | | | | | └── internal_thread_func +| 67620000000 | 4 | 5 | worker | 91.21 | | | | | | └── int gauss_db_thread_main +| 67620000000 | 5 | 6 | worker | 91.21 | | | | | | └── backend_run +| 67620000000 | 6 | 7 | worker | 91.21 | | | | | | |── PostgresMain +| 67520000000 | 7 | 8 | worker | 91.07 | | | | | | | |── exec_simple_query +| 64800000000 | 8 | 9 | worker | 87.4 | | | | | | | | |── OpFusion::opfusion_process +| 30130000000 | 9 | 10 | worker | 40.64 | | | | | | | | |── pg_analyze_and_rewrite +| 11290000000 | 9 | 1405 | worker | 15.23 | | | | | | | | |── pg_plan_queries +| 9550000000 | 9 | 2660 | worker | 12.88 | | | | | | | | |── PortalRun +| 4680000000 | 9 | 4310 | worker | 6.31 | | | | | | | | |── finish_xact_command +| 3120000000 | 9 | 4923 | worker | 4.21 | | | | | | | | |── pg_parse_query +| 1520000000 | 9 | 5262 | worker | 2.05 | | | | | | | | |── OpFusion::opfusion_factory +| 1500000000 | 9 | 5374 | worker | 2.02 | | | | | txnsnapworker +| 1640000000 | 1 | 6770 | txnsnapworker | 2.21 | | | | | |── start_thread +| 1620000000 | 2 | 6771 | txnsnapworker | 2.19 | | | | | | └── ThreadStarterFunc +| 1620000000 | 3 | 6772 | txnsnapworker | 2.19 | | | | | | └── internal_thread_func +| 1620000000 | 4 | 6773 | txnsnapworker | 2.19 | | | | | | └── int gauss_db_thread_main +| 1620000000 | 5 | 6774 | txnsnapworker | 2.19 | | | | | | └── txn_snap_cap_worker_main +| 1620000000 | 6 | 6775 | txnsnapworker | 2.19 | | | | | | └── PostgresInitializer::InitTxnSnapWorker +| 1620000000 | 7 | 6776 | txnsnapworker | 2.19 | | | | | | |── PostgresInitializer::SetDatabase +| 1600000000 | 8 | 6777 | txnsnapworker | 2.16 | | | | | | | └── PostgresInitializer::SetDatabaseByName+| 1600000000 | 9 | 6778 | txnsnapworker | 2.16
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -
gs_perf_report()
描述:根据执行gs_perf_start函数采集到的堆栈数据,生成图形化火焰图文件,保存在$GAUSSLOG/gs_flamegraph/{datanode}路径下。查询该函数需要有SYSADMIN权限或者MONADMIN权限。
参数:nan
返回值类型:text
示例:
生成火焰图火焰图文件。
| ``` gaussdb=# SELECT * FROM gs_perf_report(); gs_perf_report ------------------------------------------------------------------------- Perf report succeed, flamegraph file: flamegraph-2023-11-26_164802.html (1 row)
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -
gs_perf_clean()
描述:清理perf产生的数据。查询该函数需要有SYSADMIN权限或者MONADMIN权限。
参数:nan
返回值类型:text。
示例:
清理采集到的堆栈信息。
| ``` gaussdb=# SELECT * FROM gs_perf_clean(); gs_perf_clean --------------------- Perf clean succeed. (1 row)
| ---------------------------------------------------------------------------------------------------------------------- | -
gs_tpworker_execstmt_stat()
描述:描述语句的运行时信息,SYSADMIN和MONADMIN用户执行则显示全部正在执行的语句的信息,普通用户查询只能查询自己执行的SQL语句的信息。
返回值类型:setof record。
名称 类型 描述 db_oid oid 用户会话在后台连接到的数据库OID。 db_name name 用户会话在后台连接到的数据库名称。 threadpool_worker varchar 线程所属的numagroup和线程的ID,格式如下:numagroup_threadid。 thread_id bigint 线程ID。 session_id bigint 会话ID。 query_id bigint 正在执行的SQL语句的ID。 query_text text 正在执行的SQL语句内容。 unique_sql_id bigint SQL语句生成的唯一id。 client_hostname text 客户端的主机名,这个字段是通过client_addr的反向DNS查找得到。这个字段只有在启动log_hostname且使用IP连接时才非空。 client_app_name text 客户端app的名字。 stmt_slow_time_threshold int 单位毫秒,SQL语句被标记为慢SQL的预设超时时间。 stmt_start_time timestamp with time zone 语句执行的开始时间。 stmt_elapse_time int 距离查询开始执行时已经过去的时间。 stmt_control_status varchar 当前语句状态:- Waiting:等待状态,session接入未获得线程执行。 - Running:当前语句正常执行。
- Control:当前语句进入了资源管控阶段。 | | stmt_control_rule | text | 当前语对应的慢SQL管控规则。 | | stmt_control_iostat | text | 当前语句的iops值和最大iops上限。格式如下:curVal/maxVal。 | | stmt_control_memstat | text | 当前字段预留,暂不支持。 | | stmt_control_cpustat | text | 当前字段预留,暂不支持。 | | stmt_control_netstat | text | 当前字段预留,暂不支持。 |
-
gs_tpworker_execslot_stat()
描述:描述线程的运行时信息,SYSADMIN和MONADMIN用户执行则显示全部线程的信息,普通用户查询只能查询自己执行的SQL语句所在的线程的信息。
返回值类型:setof record。
名称 类型 描述 numagroup int 当前线程所属的numagroup。 worker_id int 当前线程的ID。 worker_bind_type text 线程绑定方式numabind, cpubind, allbind,nobind。 worker_cpu_affinity text 线程和CPU的亲和性,即线程可以调度的cpu核数范围。 worker_status varchar 当前线程状态:- Waiting:等待状态,session接入未获得线程执行。 - Running:当前语句正常执行。
- Control:当前语句进入了资源管控阶段。 | | served_query_id | bigint | 正在执行的SQL语句的ID。 | | served_query_text | text | 正在执行的SQL语句内容。 |
-
gs_session_all_settings(sessionid bigint)
描述:查询本节点上sessionid对应的session的全量GUC参数配置。需要SYSADMIN或者MONADMIN权限执行。
入参说明:sessionid,会话ID。
返回值类型:setof record。
函数返回字段说明如下:
名称 类型 描述 name text 参数名称。 setting text 参数当前值。 unit text 参数的隐式单位。 示例:
gaussdb=# SELECT sessionid FROM pg_stat_activity WHERE usename = 'testuser'; sessionid ----------- 788861 (1 row) gaussdb=# SELECT * FROM gs_session_all_settings(788861) WHERE name = 'work_mem'; name | setting | unit ----------+---------+------ work_mem | 131072 | kB (1 row) -
gs_session_all_settings()
描述:查询本节点上所有session的全量GUC参数配置。需要SYSADMIN或者MONADMIN权限执行。
返回值类型:setof record。
名称 类型 描述 sessionid bigint 会话的ID。 pid bigint 后端线程的ID。 name text 参数名称。 setting text 参数当前值。 unit text 参数的隐式单位。 示例:
gaussdb=# SELECT * FROM gs_session_all_settings() WHERE name = 'work_mem'; sessionid | pid | name | setting | unit -----------------+-----------------+----------+---------+------ 140550214145792 | 96974 | work_mem | 65536 | kB 140550214145792 | 96971 | work_mem | 65536 | kB 140549731735296 | 140549731735296 | work_mem | 65536 | kB 140549764413184 | 140549764413184 | work_mem | 65536 | kB (4 rows) -
gs_local_wal_preparse_statistics()
描述:查询本节点上日志预解析线程最近一次启动,预解析日志的情况。需要SYSADMIN权限执行。
返回值类型:setof record。
名称 类型 描述 preparser_term text 最近一次预解析日志得到的最大term值。 preparser_start_time timestamptz 最近一次预解析启动时间。 preparser_end_time timestamptz 最近一次预解析结束时间。 preparser_start_location text 最近一次预解析日志起始位置。 preparser_end_location text 最近一次预解析日志结束位置。 preparser_total_bytes int8 最近一次预解析日志量,单位:byte。 preparser_speed int8 最近一次预解析速度,单位:byte/ms。 is_valid bool 最近一次预解析结果是否可以用于选主。 示例:
gaussdb=# SELECT * FROM gs_local_wal_preparse_statistics(); preparser_term | preparser_start_time | preparser_end_time | preparser_start_location | preparser_end_location | preparser_total_bytes | preparser_speed | is_valid ----------------+-------------------------------+-------------------------------+--------------------------+------------------------+-----------------------+-----------------+---------- 3107 | 2023-02-01 17:04:23.367946+08 | 2023-02-01 17:04:25.354434+08 | 00000003/C3EEA660 | 00000004/0BE60738 | 1207394520 | 1207394520 | f (1 row) -
gs_hot_standby_space_info()
描述:查询standby_read/base_page,standby_read/block_info_meta,standby_read/lsn_info_meta文件夹中的文件总数和总大小。
返回值类型:setof record。
名称 类型 描述 base_page_file_num xid bage_page_file的总数量。 base_page_total_size xid bage_page_file的总大小。 lsn_info_meta_file_num xid lsn_info_meta_file的总数量。 lsn_info_meta_total_size xid lsn_info_meta_file的总大小。 block_info_meta_file_num xid block_info_meta_file的总数量。 block_info_meta_total_size xid block_info_meta_file的总大小。 示例:
gaussdb=# SELECT * FROM gs_hot_standby_space_info(); base_page_file_num | base_page_total_size | lsn_info_meta_file_num | lsn_info_meta_total_size | block_info_meta_file_num | block_info_meta_total_size --------------------+----------------------+------------------------+--------------------------+--------------------------+---------------------------- 6 | 163840 | 6 | 3136 | 16 | 147456 (1 row)
-
exrto_file_read_stat()
描述:查询备机读新增的base page file、lsn info meta file和block info meta file三种类型的文件磁盘访问次数和访问总时延。连接备DN查询,其他情况查询结果为0。
返回值类型:setof record。
名称 类型 描述 lsn_info_page_disk_read_counter int8 lsn info meta file的磁盘访问次数。 lsn_info_page_disk_read_dur int8 lsn info meta file的磁盘访问总时延。 blk_info_meta_disk_read_counter int8 block info meta file的磁盘访问次数。 blk_info_meta_disk_read_dur int8 block info meta file的磁盘访问总时延。 base_page_read_disk_counter int8 base page file的磁盘访问次数。 base_page_read_disk_dur int8 base page file的磁盘访问总时延。 示例:
gaussdb=# SELECT * FROM exrto_file_read_stat(); lsn_info_page_disk_read_counter | lsn_info_page_disk_read_dur | blk_info_meta_disk_read_counter | blk_info_meta_disk_read_dur | base_page_read_disk_counter | base_page_read_disk_dur ---------------------------------+-----------------------------+---------------------------------+-----------------------------+-----------------------------+------------------------- 14987 | 92313 | 23879 | 129811 | 0 | 0 (1 row)
-
gs_exrto_recycle_info()
描述:查询资源回收位置,其中包括每个线程的回收lsn,全局回收的lsn,查询线程最旧的快照的lsn。连接备DN查询,其他情况查询结果为0。
返回值类型:setof record。
名称 类型 描述 page_redo_worker_thread_id text redo线程的回收lsn位置,其中thread_id为redo线程的线程id。 global_recycle_lsn text 全局回收位置的lsn。 exrto_snapshot_oldest_lsn text 查询线程的最旧的快照lsn。 示例:
gaussdb=# SELECT * FROM gs_exrto_recycle_info(); thread_id | recycle_lsn ----------------------------------+------------- page_redo_worker_140148895381248 | 0/7B4552E0 page_redo_worker_140148872312576 | 0/7B4535B8 global_recycle_lsn | 0/7B4535B8 exrto_snapshot_oldest_lsn | 0/8488E6D0 (4 rows) -
gs_stat_get_db_conflict_all(oid)
描述:查询发送回放冲突信号的数量。
返回值类型:setof record。
名称 类型 描述 conflict_all int8 发送回放冲突信号的总数量。 conflict_tablespace int8 发送tablespace类型回放冲突信号的数量。 conflict_lock int8 发送lock类型回放冲突信号的数量。 conflict_snapshot int8 发送snapshot类型回放冲突信号的数量。 conflict_bufferpin int8 发送bufferpin类型回放冲突信号的数量。 conflict_startup_deadlock int8 发送startup_deadlock类型回放冲突信号的数量。 conflict_truncate int8 发送truncate类型回放冲突信号的数量。 conflict_standby_query_timeout int8 发送standby_query_timeout类型回放冲突信号的数量。 conflict_force_recycle int8 发送force_recycle类型回放冲突信号的数量。 示例:
gaussdb=# SELECT * FROM gs_stat_get_db_conflict_all(12738); conflict_all | conflict_tablespace | conflict_lock | conflict_snapshot | conflict_bufferpin | conflict_startup_deadlock | conflict_truncate | conflict_standby_query_timeout | conflict_force_recycle --------------+---------------------+---------------+-------------------+--------------------+---------------------------+-------------------+--------------------------------+------------------------ 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 (1 row)
-
gs_redo_stat_info()
描述:查询回放信息,包括回放线程的buffer命中率、执行unlink_rels文件数量、极致RTO场景下回放线程读取buffer时产生io操作的waitevent信息以及wal_read_from_write_buffer的waitevent信息。需要连接备DN查询。
返回值类型:setof record。
名称 类型 描述 buffer_hit_rate float8 回放线程的buffer命中率。 ddl_unlink_nrels_count int8 回放ddl操作执行unlink rel文件的数量。 read_buffer_io_counter int8 极致RTO场景下回放线程读取buffer时产生io操作的waitevent触发次数。 read_buffer_io_total_dur int8 极致RTO场景下回放线程读取buffer时产生io操作的waitevent总用时。 read_buffer_io_avg_dur int8 极致RTO场景下回放线程读取buffer时产生io操作的waitevent平均用时。 read_buffer_io_min_dur int8 极致RTO场景下回放线程读取buffer时产生io操作的waitevent最小用时。 read_buffer_io_max_dur int8 极致RTO场景下回放线程读取buffer时产生io操作的waitevent最大用时。 read_wal_buf_counter int8 极致RTO场景下wal_read_from_write_buffer的waitevent触发次数。 read_wal_buf_total_dur int8 极致RTO场景下wal_read_from_write_buffer的waitevent总用时。 read_wal_buf_avg_dur int8 极致RTO场景下wal_read_from_write_buffer的waitevent平均用时。 read_wal_buf_min_dur int8 极致RTO场景下wal_read_from_write_buffer的waitevent最小用时。 read_wal_buf_max_dur int8 极致RTO场景下wal_read_from_write_buffer的waitevent最大用时。 示例:
gaussdb=# SELECT * FROM gs_redo_stat_info(); -[ RECORD 1 ]------------+---------- buffer_hit_rate | 70.5707 ddl_unlink_nrels_count | 3 read_buffer_io_counter | 1732 read_buffer_io_total_dur | 2850806 read_buffer_io_avg_dur | 1645 read_buffer_io_min_dur | 3 read_buffer_io_max_dur | 981639 read_wal_buf_counter | 9779 read_wal_buf_total_dur | 193612470 read_wal_buf_avg_dur | 19798 read_wal_buf_min_dur | 3 read_wal_buf_max_dur | 1914777
-
gs_recovery_conflict_waitevent_info()
描述:查询处理回放冲突的函数的waitevent相关信息。需要连接备DN查询。
返回值类型:setof record。
名称 类型 描述 conflict_lock_counter int8 处理lock类型回放冲突的触发次数。 conflict_lock_total_dur int8 处理lock类型回放冲突的总用时。 conflict_lock_avg_dur int8 处理lock类型回放冲突的平均用时。 conflict_lock_min_dur int8 处理lock类型回放冲突的最小用时。 conflict_lock_max_dur int8 处理lock类型回放冲突的最大用时。 conflict_snapshot_counter int8 处理snapshot类型回放冲突的触发次数。 conflict_snapshot_total_dur int8 处理snapshot类型回放冲突的总用时。 conflict_snapshot_avg_dur int8 处理snapshot类型回放冲突的平均用时。 conflict_snapshot_min_dur int8 处理snapshot类型回放冲突的最小用时。 conflict_snapshot_max_dur int8 处理snapshot类型回放冲突的最大用时。 conflict_tablespace_counter int8 处理tablespace类型回放冲突的触发次数。 conflict_tablespace_total_dur int8 处理tablespace类型回放冲突的总用时。 conflict_tablespace_avg_dur int8 处理tablespace类型回放冲突的平均用时。 conflict_tablespace_min_dur int8 处理tablespace类型回放冲突的最小用时。 conflict_tablespace_max_dur int8 处理tablespace类型回放冲突的最大用时。 conflict_database_counter int8 处理database类型回放冲突的触发次数。 conflict_database_total_dur int8 处理database类型回放冲突的总用时。 conflict_database_avg_dur int8 处理database类型回放冲突的平均用时。 conflict_database_min_dur int8 处理database类型回放冲突的最小用时。 conflict_database_max_dur int8 处理database类型回放冲突的最大用时。 conflict_truncate_counter int8 处理truncate类型回放冲突的触发次数。 conflict_truncate_total_dur int8 处理truncate类型回放冲突的总用时。 conflict_truncate_avg_dur int8 处理truncate类型回放冲突的平均用时。 conflict_truncate_min_dur int8 处理truncate类型回放冲突的最小用时。 conflict_truncate_max_dur int8 处理truncate类型回放冲突的最大用时。 conflict_standby_query_timeout_counter int8 处理standby_query_timeout类型回放冲突的触发次数。 conflict_standby_query_timeout_total_dur int8 处理standby_query_timeout类型回放冲突的总用时。 conflict_standby_query_timeout_avg_dur int8 处理standby_query_timeout类型回放冲突的平均用时。 conflict_standby_query_timeout_min_dur int8 处理standby_query_timeout类型回放冲突的最小用时。 conflict_standby_query_timeout_max_dur int8 处理standby_query_timeout类型回放冲突的最大用时。 conflict_force_recycle_counter int8 处理force_recycle类型回放冲突的触发次数。 conflict_force_recycle_total_dur int8 处理force_recycle类型回放冲突的总用时。 conflict_force_recycle_avg_dur int8 处理force_recycle类型回放冲突的平均用时。 conflict_force_recycle_min_dur int8 处理force_recycle类型回放冲突的最小用时。 conflict_force_recycle_max_dur int8 处理force_recycle类型回放冲突的最大用时。 示例:
gaussdb=# SELECT * FROM gs_recovery_conflict_waitevent_info(); -[ RECORD 1 ]----------------------------+------ conflict_lock_counter | 0 conflict_lock_total_dur | 0 conflict_lock_avg_dur | 0 conflict_lock_min_dur | 0 conflict_lock_max_dur | 0 conflict_snapshot_counter | 0 conflict_snapshot_total_dur | 0 conflict_snapshot_avg_dur | 0 conflict_snapshot_min_dur | 0 conflict_snapshot_max_dur | 0 conflict_tablespace_counter | 0 conflict_tablespace_total_dur | 0 conflict_tablespace_avg_dur | 0 conflict_tablespace_min_dur | 0 conflict_tablespace_max_dur | 0 conflict_database_counter | 0 conflict_database_total_dur | 0 conflict_database_avg_dur | 0 conflict_database_min_dur | 0 conflict_database_max_dur | 0 conflict_truncate_counter | 6 conflict_truncate_total_dur | 35872 conflict_truncate_avg_dur | 5978 conflict_truncate_min_dur | 5130 conflict_truncate_max_dur | 7459 conflict_standby_query_timeout_counter | 0 conflict_standby_query_timeout_total_dur | 0 conflict_standby_query_timeout_avg_dur | 0 conflict_standby_query_timeout_min_dur | 0 conflict_standby_query_timeoutmax_dur | 0 conflict_force_recycle_counter | 0 conflict_force_recycle_total_dur | 0 conflict_force_recycle_avg_dur | 0 conflict_force_recycle_min_dur | 0 conflict_force_recycle_max_dur | 0
-
gs_display_delay_ddl_info()
返回值类型:setof record。
名称 类型 描述 type INT4 删除操作的对象是表或数据库。 lsn TEXT 标识特定日志文件记录在此日志文件中的位置。 tablespace INT4 数据库中用于存储表和索引的物理空间。 database INT4 该数据库的物理存储位置。 relation INT4 数据库中的对象,可以是表、视图、索引的物理位置。 bucketid INT4 指定关系对象所属的bucket。 opt INT4 压缩表相关属性。 forknum INT4 主体命名之后的后缀命名,通过主体命名和后缀命名,可以找到唯一的物理文件。 示例:
gaussdb=# SELECT * FROM gs_display_delay_ddl_info(); type | lsn | tablespace | database | relation | bucketid | opt | forknum ------+-----+------------+----------+----------+----------+-----+--------- (0 rows)
分区表统计信息函数
-
gs_stat_get_partition_stats(oid)
返回值类型:record。
-
gs_stat_get_xact_partition_stats(oid)
返回值类型:record。
-
gs_stat_get_all_partitions_stats()
返回值类型:setof record。
-
gs_stat_get_xact_all_partitions_stats()
返回值类型:setof record。
-
gs_statio_get_all_partitions_stats()
返回值类型:setof record。
上述五个函数示例:
运行时统计信息上报是异步的,且基于UDP协议,后台线程处理可能存在延迟和丢包,此处示例预期仅供参考。
事务外统计信息查询:
gaussdb=# CREATE TABLE part_tab1 gaussdb-# ( gaussdb(# a int, b int gaussdb(# ) gaussdb-# PARTITION BY RANGE(b) gaussdb-# ( gaussdb(# PARTITION P1 VALUES LESS THAN(10), gaussdb(# PARTITION P2 VALUES LESS THAN(20), gaussdb(# PARTITION P3 VALUES LESS THAN(MAXVALUE) gaussdb(# ); CREATE TABLE gaussdb=# CREATE TABLE subpart_tab1 gaussdb-# ( gaussdb(# month_code VARCHAR2 ( 30 ) NOT NULL , gaussdb(# dept_code VARCHAR2 ( 30 ) NOT NULL , gaussdb(# user_no VARCHAR2 ( 30 ) NOT NULL , gaussdb(# sales_amt int gaussdb(# ) gaussdb-# PARTITION BY RANGE (month_code) SUBPARTITION BY RANGE (dept_code) gaussdb-# ( gaussdb(# PARTITION p_201901 VALUES LESS THAN( '201903' ) gaussdb(# ( gaussdb(# SUBPARTITION p_201901_a VALUES LESS THAN( '2' ), gaussdb(# SUBPARTITION p_201901_b VALUES LESS THAN( '3' ) gaussdb(# ), gaussdb(# PARTITION p_201902 VALUES LESS THAN( '201904' ) gaussdb(# ( gaussdb(# SUBPARTITION p_201902_a VALUES LESS THAN( '2' ), gaussdb(# SUBPARTITION p_201902_b VALUES LESS THAN( '3' ) gaussdb(# ) gaussdb(# ); CREATE TABLE gaussdb=# CREATE INDEX index_part_tab1 ON part_tab1(b) LOCAL gaussdb-# ( gaussdb(# PARTITION b_index1, gaussdb(# PARTITION b_index2, gaussdb(# PARTITION b_index3 gaussdb(# ); CREATE INDEX gaussdb=# CREATE INDEX idx_user_no ON subpart_tab1(user_no) LOCAL; CREATE INDEX gaussdb=# INSERT INTO part_tab1 VALUES(1, 1); INSERT 0 1 gaussdb=# INSERT INTO part_tab1 VALUES(1, 11); INSERT 0 1 gaussdb=# INSERT INTO part_tab1 VALUES(1, 21); INSERT 0 1 gaussdb=# UPDATE part_tab1 SET a = 2 WHERE b = 1; UPDATE 1 gaussdb=# UPDATE part_tab1 SET a = 3 WHERE b = 11; UPDATE 1 gaussdb=# UPDATE /*+ indexscan(part_tab1) */ part_tab1 SET a = 4 WHERE b = 21; UPDATE 1 gaussdb=# DELETE FROM part_tab1; DELETE 3 gaussdb=# ANALYZE part_tab1; ANALYZE gaussdb=# VACUUM part_tab1; VACUUM gaussdb=# INSERT INTO subpart_tab1 VALUES('201902', '1', '1', 1); INSERT 0 1 gaussdb=# INSERT INTO subpart_tab1 VALUES('201902', '2', '2', 1); INSERT 0 1 gaussdb=# INSERT INTO subpart_tab1 VALUES('201903', '1', '3', 1); INSERT 0 1 gaussdb=# INSERT INTO subpart_tab1 VALUES('201903', '2', '4', 1); INSERT 0 1 gaussdb=# UPDATE subpart_tab1 SET sales_amt = 2 WHERE user_no='1'; UPDATE 1 gaussdb=# UPDATE subpart_tab1 SET sales_amt = 3 WHERE user_no='2'; UPDATE 1 gaussdb=# UPDATE subpart_tab1 SET sales_amt = 4 WHERE user_no='3'; UPDATE 1 gaussdb=# UPDATE /*+ indexscan(subpart_tab1) */ subpart_tab1 SET sales_amt = 5 WHERE user_no='4'; UPDATE 1 gaussdb=# DELETE FROM subpart_tab1; DELETE 4 gaussdb=# ANALYZE subpart_tab1; ANALYZE gaussdb=# VACUUM subpart_tab1; VACUUM gaussdb=# SELECT * FROM gs_stat_all_partitions; partition_oid | schemaname | relname | partition_name | sub_partition_name | seq_scan | seq_tup_read | idx_scan | idx_tup_fetch | n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | last_vacuum | last_autovacuum | last_analyze | last_autoanalyze | vacuum_count | autovacuum_count | analyze_count | autoanalyze_count ---------------+------------+--------------+----------------+--------------------+----------+--------------+----------+---------------+-----------+-----------+-----------+---------------+------------+ ------------+-------------------------------+------------------------+-------------------------------+------------------------+--------------+------------------+---------------+------------------- 16964 | public | subpart_tab1 | p_201902 | p_201902_b | 5 | 1 | 4 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 2023-05-15 20:36:45.293965+08 | 2000-01-01 08:00:00+08 | 2023-05-15 20:36:44.688861+08 | 2000-01-01 08:00:00+08 | 1 | 0 | 1 | 0 16963 | public | subpart_tab1 | p_201902 | p_201902_a | 5 | 1 | 4 | 0 | 1 | 1 | 1 | 1 | 0 | 1 | 2023-05-15 20:36:45.291022+08 | 2000-01-01 08:00:00+08 | 2023-05-15 20:36:44.688843+08 | 2000-01-01 08:00:00+08 | 1 | 0 | 1 | 0 16961 | public | subpart_tab1 | p_201901 | p_201901_b | 5 | 1 | 4 | 0 | 1 | 1 | 1 | 1 | 0 | 1 | 2023-05-15 20:36:45.288037+08 | 2000-01-01 08:00:00+08 | 2023-05-15 20:36:44.688829+08 | 2000-01-01 08:00:00+08 | 1 | 0 | 1 | 0 16960 | public | subpart_tab1 | p_201901 | p_201901_a | 5 | 1 | 4 | 0 | 1 | 1 | 1 | 1 | 0 | 1 | 2023-05-15 20:36:45.285311+08 | 2000-01-01 08:00:00+08 | 2023-05-15 20:36:44.688802+08 | 2000-01-01 08:00:00+08 | 1 | 0 | 1 | 0 16954 | public | part_tab1 | p3 | | 2 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 2023-05-15 20:36:29.490636+08 | 2000-01-01 08:00:00+08 | 2023-05-15 20:36:28.540115+08 | 2000-01-01 08:00:00+08 | 1 | 0 | 1 | 0 16953 | public | part_tab1 | p2 | | 4 | 1 | 1 | 0 | 1 | 1 | 1 | 1 | 0 | 1 | 2023-05-15 20:36:29.487914+08 | 2000-01-01 08:00:00+08 | 2023-05-15 20:36:28.540098+08 | 2000-01-01 08:00:00+08 | 1 | 0 | 1 | 0 16952 | public | part_tab1 | p1 | | 5 | 1 | 1 | 0 | 1 | 1 | 1 | 1 | 0 | 1 | 2023-05-15 20:36:29.48536+08 | 2000-01-01 08:00:00+08 | 2023-05-15 20:36:28.540071+08 | 2000-01-01 08:00:00+08 | 1 | 0 | 1 | 0 (7 rows) gaussdb=# SELECT * FROM gs_statio_all_partitions; partition_oid | schemaname | relname | partition_name | sub_partition_name | heap_blks_read | heap_blks_hit | idx_blks_read | idx_blks_hit | toast_blks_read | toast_blks_hit | tidx_blks_read | t idx_blks_hit ---------------+------------+--------------+----------------+--------------------+----------------+---------------+---------------+--------------+-----------------+----------------+----------------+-- ------------- 16964 | public | subpart_tab1 | p_201902 | p_201902_b | 4 | 8 | 2 | 21 | | | | 16963 | public | subpart_tab1 | p_201902 | p_201902_a | 4 | 8 | 2 | 21 | | | | 16961 | public | subpart_tab1 | p_201901 | p_201901_b | 4 | 8 | 2 | 21 | | | | 16960 | public | subpart_tab1 | p_201901 | p_201901_a | 4 | 8 | 2 | 21 | | | | 16954 | public | part_tab1 | p3 | | 4 | 8 | 2 | 15 | | | | 16953 | public | part_tab1 | p2 | | 4 | 8 | 2 | 15 | | | | 16952 | public | part_tab1 | p1 | | 4 | 8 | 2 | 15 | | | | (7 rows) gaussdb=# SELECT * FROM gs_stat_get_partition_stats(16952); partition_oid | seq_scan | seq_tup_read | idx_scan | idx_tup_fetch | n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | last_vacuum | last_autovacuum | last_analyze | last_autoanalyze | vacuum_count | autovacuum_count | analyze_count | autoanalyze_count | last_data_changed | heap_blks_read | heap_blks_hit | idx_blks_re ad | idx_blks_hit | tup_fetch | block_fetch ---------------+----------+--------------+----------+---------------+-----------+-----------+-----------+---------------+------------+------------+------------------------------+---------------------- --+-------------------------------+------------------------+--------------+------------------+---------------+-------------------+------------------------+----------------+---------------+------------ ---+--------------+-----------+------------- 16952 | 5 | 1 | 1 | 0 | 1 | 1 | 1 | 1 | 0 | 1 | 2023-05-15 20:36:29.48536+08 | 2000-01-01 08:00:00+0 8 | 2023-05-15 20:36:28.540071+08 | 2000-01-01 08:00:00+08 | 1 | 0 | 1 | 0 | 2000-01-01 08:00:00+08 | 4 | 8 | 2 | 21 | 0 | 12 (1 row)事务内统计信息查询:
gaussdb=# BEGIN; BEGIN gaussdb=# INSERT INTO part_tab1 VALUES(1, 1); INSERT 0 1 gaussdb=# INSERT INTO part_tab1 VALUES(1, 11); INSERT 0 1 gaussdb=# INSERT INTO part_tab1 VALUES(1, 21); INSERT 0 1 gaussdb=# UPDATE part_tab1 SET a = 2 WHERE b = 1; UPDATE 1 gaussdb=# UPDATE part_tab1 SET a = 3 WHERE b = 11; UPDATE 1 gaussdb=# UPDATE /*+ indexscan(part_tab1) */ part_tab1 SET a = 4 WHERE b = 21; UPDATE 1 gaussdb=# DELETE FROM part_tab1; DELETE 3 gaussdb=# INSERT INTO subpart_tab1 VALUES('201902', '1', '1', 1); INSERT 0 1 gaussdb=# INSERT INTO subpart_tab1 VALUES('201902', '2', '2', 1); INSERT 0 1 gaussdb=# INSERT INTO subpart_tab1 VALUES('201903', '1', '3', 1); INSERT 0 1 gaussdb=# INSERT INTO subpart_tab1 VALUES('201903', '2', '4', 1); INSERT 0 1 gaussdb=# UPDATE subpart_tab1 SET sales_amt = 2 WHERE user_no='1'; UPDATE 1 gaussdb=# UPDATE subpart_tab1 SET sales_amt = 3 WHERE user_no='2'; UPDATE 1 gaussdb=# UPDATE subpart_tab1 SET sales_amt = 4 WHERE user_no='3'; UPDATE 1 gaussdb=# UPDATE /*+ indexscan(subpart_tab1) */ subpart_tab1 SET sales_amt = 5 WHERE user_no='4'; UPDATE 1 gaussdb=# DELETE FROM subpart_tab1; DELETE 4 gaussdb=# SELECT * FROM gs_stat_xact_all_partitions; partition_oid | schemaname | relname | partition_name | sub_partition_name | seq_scan | seq_tup_read | idx_scan | idx_tup_fetch | n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd ---------------+------------+--------------+----------------+--------------------+----------+--------------+----------+---------------+-----------+-----------+-----------+--------------- 16964 | public | subpart_tab1 | p_201902 | p_201902_b | 4 | 4 | 1 | 2 | 1 | 1 | 1 | 1 16963 | public | subpart_tab1 | p_201902 | p_201902_a | 4 | 4 | 1 | 0 | 1 | 1 | 1 | 1 16961 | public | subpart_tab1 | p_201901 | p_201901_b | 4 | 4 | 1 | 0 | 1 | 1 | 1 | 1 16960 | public | subpart_tab1 | p_201901 | p_201901_a | 4 | 4 | 1 | 0 | 1 | 1 | 1 | 1 16954 | public | part_tab1 | p3 | | 1 | 1 | 1 | 2 | 1 | 1 | 1 | 1 16953 | public | part_tab1 | p2 | | 3 | 2 | 0 | 0 | 1 | 1 | 1 | 1 16952 | public | part_tab1 | p1 | | 4 | 2 | 0 | 0 | 1 | 1 | 1 | 1 (7 rows) gaussdb=# SELECT * FROM gs_stat_get_xact_partition_stats(16952); partition_oid | seq_scan | seq_tup_read | idx_scan | idx_tup_fetch | n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | tup_fetch ---------------+----------+--------------+----------+---------------+-----------+-----------+-----------+---------------+----------- 16952 | 4 | 2 | 0 | 0 | 1 | 1 | 1 | 1 | 0 (1 row) -
gs_stat_get_partition_analyze_count(oid)
返回值类型:bigint。
-
gs_stat_get_partition_autoanalyze_count(oid)
描述:autovacuum守护线程在该分区上启动分析的次数。
返回值类型:bigint。
-
gs_stat_get_partition_autovacuum_count(oid)
描述:autovacuum守护线程在该分区上启动清理的次数。
返回值类型:bigint。
-
gs_stat_get_partition_last_analyze_time(oid)
描述:用户在该分区上最后一次手动启动分析或者autovacuum线程启动分析的时间。
返回值类型:timestamptz。
-
gs_stat_get_partition_last_autoanalyze_time(oid)
描述:autovacuum守护线程在该分区上最后一次启动分析的时间。
返回值类型:timestamptz。
-
gs_stat_get_partition_last_autovacuum_time(oid)
描述:autovacuum守护线程在该分区上最后一次启动清理的时间。
返回值类型:timestamptz。
-
gs_stat_get_partition_last_data_changed_time(oid)
描述:对于在分区上的修改insert/update/delete/truncate,在该表上最后一次操作的时间。当前暂不支持。
返回值类型:timestamptz。
-
gs_stat_get_partition_last_vacuum_time(oid)
描述:用户在该分区上最后一次手动启动清理或者autovacuum线程启动清理的时间。
返回值类型:timestamptz。
-
gs_stat_get_partition_numscans(oid)
返回值类型:bigint。
-
gs_stat_get_partition_tuples_returned(oid)
返回值类型:bigint。
-
gs_stat_get_partition_tuples_fetched(oid)
返回值类型:bigint
-
gs_stat_get_partition_vacuum_count(oid)
返回值类型:bigint。
-
gs_stat_get_xact_partition_tuples_fetched(oid)
返回值类型:bigint。
-
gs_stat_get_xact_partition_numscans(oid)
返回值类型:bigint。
-
gs_stat_get_xact_partition_tuples_returned(oid)
返回值类型:bigint。
-
gs_stat_get_partition_blocks_fetched(oid)
返回值类型:bigint。
-
gs_stat_get_partition_blocks_hit(oid)
返回值类型:bigint。
-
pg_stat_get_partition_tuples_inserted(oid)
返回值类型:bigint。
-
pg_stat_get_partition_tuples_updated(oid)
返回值类型:bigint。
-
pg_stat_get_partition_tuples_deleted(oid)
返回值类型:bigint。
-
pg_stat_get_partition_tuples_changed(oid)
描述:该表分区上一次analyze或autoanalyze之后插入、更新、删除行的总数量。
返回值类型:bigint。
-
pg_stat_get_partition_live_tuples(oid)
返回值类型:bigint。
-
pg_stat_get_partition_dead_tuples(oid)
返回值类型:bigint。
-
pg_stat_get_xact_partition_tuples_inserted(oid)
返回值类型:bigint。
-
pg_stat_get_xact_partition_tuples_deleted(oid)
返回值类型:bigint。
-
pg_stat_get_xact_partition_tuples_hot_updated(oid)
返回值类型:bigint。
-
pg_stat_get_xact_partition_tuples_updated(oid)
返回值类型:bigint。
-
pg_stat_get_partition_tuples_hot_updated(oid)
参数:oid
返回值类型:bigint。
-
gs_wlm_respool_cpu_info()
返回值类型:setof record。
名称 类型 描述 respool_name name 资源池名称。 control_group name cgroup名称。 cpu_affinity name CPU绑定core的数值。 cpu_usage integer 资源池的CPU使用率。 对于CN和DN混合部署的场景,CN和DN共享同一份CPU资源,因此CN和DN的cpu_usage显示相同,对于CN和DN独立部署场景,会独立显示。
示例:
| ``` gaussdb=# SELECT * FROM GS_WLM_RESPOOL_CPU_INFO(); respool_name | control_group | cpu_affinity | cpu_usage ---------------+----------------------+--------------+----------- respool_cpu_2 | respool_cpu_2:Medium | 0-95 | 78 default_pool | DefaultClass:Medium | 0-32 | 65 (2 rows)
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -
gs_wlm_respool_connection_info()
返回值类型:setof record。
名称 类型 描述 respool_name name 资源池名称。 max_connections name 资源池最大连接数。 curr_connections integer 当前资源池已有连接数。 示例:
| ``` gaussdb=# SELECT * FROM GS_WLM_RESPOOL_CONNECTION_INFO(); respool_name | max_connections | curr_connections ---------------+-----------------+------------------ respool1 | -1 | 0 default_pool | -1 | 1 (2 rows)
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -
gs_wlm_respool_memory_info()
返回值类型:setof record
名称 类型 描述 respool_name name 资源池名称。 max_dynamic_memory integer 最大可使用的动态内存。 current_dynamic_memory integer 当前已经使用的动态内存。 max_shared_memory integer 最大可使用的共享内存。 current_shared_memory integer 当前已经使用的共享内存。 shared_memory_hits_percent integer 当前资源池所在的缓存命中率。 在出现资源池动态内存使用超过最大值时,可能会出现查询GUC参数current_dynamic_memory返回的结果大于max_dynamic_memory的情况,这属于正常现象,实际并未申请内存。
示例:
| ``` gaussdb=# SELECT * FROM GS_WLM_RESPOOL_MEMORY_INFO(); respool_name | max_dynamic_memory | current_dynamic_memory | max_shared_memory | current_shared_memory | shared_memory_hits_percent -----------------+--------------------+------------------------+-------------------+-----------------------+---------------------------- default_pool | -1 | 3383kB | -1 | 3848kB | 90 resource_pool_a | 30720kB | 0kB | -1 | 0kB | 0 (2 rows)
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -
gs_wlm_respool_concurrency_info()
返回值类型:setof record
名称 类型 描述 respool_name name 资源池名称。 max_concurrency integer 资源池支持的最大并发数。 running_conurrency integer 当前资源池正在执行的并发数。 waiting_concurrency integer 当前资源池正在等待的并发数。 示例:
gaussdb=# SELECT * FROM GS_WLM_RESPOOL_CONCURRENCY_INFO(); respool_name | max_concurrency | running_concurrency | waiting_concurrency -----------------+-----------------+---------------------+--------------------- default_pool | -1 | 1 | 0 resource_pool_a | -1 | 0 | 0 (2 rows) -
gs_wlm_respool_io_info()
返回值类型:setof record
名称 类型 描述 respool_name name 资源池名称。 io_limits integer 每秒触发I/O的次数上限。0表示不控制。- 单位:GUC参数io_control_unit,I/O管控时用来对I/O次数进行计数的单位。1个io_control_unit次为1次IOPS。 io_priority text I/O利用率高达90%时,消耗I/O作业进行I/O资源管控时关联的优先级等级。None表示不控制。 current_iops integer 当前I/O已经触发的次数。当前I/O统计值存在偶尔超过上限的情况,与I/O统计算法有关,属于正常波动。 示例:
gaussdb=# SELECT * FROM GS_WLM_RESPOOL_IO_INFO(); respool_name | io_limits | io_priority | current_iops -----------------+-----------+-------------+-------------- default_pool | 0 | None | 0 resource_pool_a | 0 | Low | 0 (2 rows) -
gs_wlm_user_space_info()
返回值类型:setof record
名称 类型 描述 user_name name 用户名称。 max_permanent_space bigint 用户可使用的最大永久存储空间,单位:B。 current_ permanent_space bigint 当前用户已使用的永久存储空间,单位:B。 max_temp_space bigint 用户可使用的最大临时存储空间,单位:B。 current_ temp_space bigint 当前用户已使用的临时存储空间,单位:B。 max_spill_space bigint 用户可使用的最大算子落盘存储空间,单位:B。 current_ spill_space bigint 当前用户已使用的算子落盘存储空间,单位:B。 示例:
| ``` gaussdb=# SELECT * FROM GS_WLM_USER_SPACE_INFO(); user_name | max_permanent_space | current_permanent_space | max_temp_space | current_temp_space | max_spill_space | current_spill_space -----------------------------+---------------------+-------------------------+----------------+--------------------+-----------------+--------------------- xy | -1 | 2464 | -1 | 0 | -1 | 0 (1 rows)
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -
gs_wlm_session_io_info()
返回值类型:setof record
名称 类型 描述。 session_id integer 会话ID。 io_limits integer 每秒触发I/O的次数上限。0表示不控制。- 单位:GUC参数io_control_unit,I/O管控时用来对I/O次数进行计数的单位。1个io_control_unit次为1次IOPS。 io_priority text I/O利用率高达90%时,消耗I/O作业进行I/O资源管控时关联的优先级等级。None表示不控制。 current_iops integer 当前I/O已经触发的次数。当前I/O统计值存在偶尔超过上限的情况,与I/O统计算法有关,属于正常波动。 wait_time integer 当前I/O超过上限后等待的时间总和。 示例:
| ``` gaussdb=# SELECT * FROM GS_WLM_SESSION_IO_INFO(); session_id | io_limits | io_priority | current_iops | wait_time -----------------+-----------+-------------+--------------+----------- 139976325986048 | 10 | None | 0 | 2709 (1 row)
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -
gs_wlm_session_memory_info()
返回值类型:setof record
名称 类型 描述 session_id integer session_id。 sess_used_dynamic_memory bigint 当前已经使用的动态内存,单位为B。 sess_max_dynamic_memory bigint 最大可使用的动态内存,单位为B。 示例:
| ``` gaussdb=# SELECT * FROM GS_WLM_SESSION_MEMORY_INFO(); sessid | sess_used_dynamic_memory | sess_max_dynamic_memory -----------------+--------------------------+------------------------- 139976325986048 | 4326056 | -1 139976402532096 | 4452664 | -1 (2 rows)
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 更多详情请参考GaussDB 文档中心:<https://doc.hcs.huawei.com/db/zh-cn/gaussdbqlh/24.1.30/productdesc/qlh_03_0001.html>