首页 > 数据库 > > 资源监控-历史TopSQL
系统提供了query级别和算子级别的资源监控历史视图用例查询历史TopSQL。资源监控历史视图记录了查询作业运行结束时的资源使用情况(包括内存、下盘、CPU时间、IO等)和运行状态信息(包括报错、终止、异常等)以及性能告警信息。但对于由于FATAL、PANIC错误导致查询异常结束时,状态信息列只显示aborted,无法记录详细异常信息。特别的,对于查询解析,优化阶段的状态信息则无法监控。
历史视图具体的对外接口如下表所示:
视图级别 | 节点范围 | 查询视图 | |
|---|---|---|---|
Query级别 | 当前CN | 历史(Database Manager接口) | gs_wlm_session_history |
历史(内部转储接口) | gs_wlm_session_info | ||
所有CN | 历史(Database Manager接口) | pgxc_wlm_session_history | |
历史(内部转储接口) | pgxc_wlm_session_info | ||
算子级别 | 当前CN | 历史(Database Manager接口) | gs_wlm_operator_history |
历史(内部转储接口) | gs_wlm_operator_info | ||
所有CN | 历史(Database Manager接口) | pgxc_wlm_operator_history | |
历史(内部转储接口) | pgxc_wlm_operator_info | ||
说明:1. 对外接口通过不同的前缀(gs与pgxc)来区分单CN查询视图以及集群级别查询视图。普通用户仅支持登录到集群的某个CN查询以gs为前缀的视图。
2. 对于gs_wlm_session_info,gs_wlm_operator_info,pgxc_wlm_session_info以及pgxc_wlm_operator_info视图只支持在连接postgres数据库时查询。
gsql -d postgres -p 25308postgres为需要连接的数据库名称,25308为CN的端口号。
连接成功后,系统显示类似如下信息:
gsql ((GaussDB Kernel V300R002C00 build 50dc16a6) compiled at 2019-01-29 05:49:21 commit 1071 last mr 1373)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=#
SELECT * FROM gs_wlm_session_history;通过视图pgxc_wlm_session_history查询所有CN最近执行作业结束后的负载记录。
SELECT * FROM pgxc_wlm_session_history;通过数据表gs_wlm_session_info查询当前CN作业执行结束后的负载记录。要查到历史记录,必须保证enable_resource_record为on。
SELECT * FROM gs_wlm_session_info;消耗内存最多的10个QuerySELECT * FROM gs_wlm_session_info order by max_peak_memory desc limit 10;消耗CPU最多的10个QuerySELECT * FROM gs_wlm_session_info order by total_cpu_time desc limit 10;通过视图pgxc_wlm_session_info查询所有CN的作业执行结束后的负载记录。要查到历史记录,必须保证enable_resource_record为on。
SELECT * FROM pgxc_wlm_session_info;查询所有CN消耗时间最多的10个querySELECT * FROM pgxc_wlm_session_info order by duration desc limit 10;通过视图gs_wlm_operator_history查询当前CN作业算子最近执行资源信息。要查到记录,必须保证resource_track_level为operator。
postgres=# SELECT * FROM gs_wlm_operator_history;通过视图pgxc_wlm_operator_history查询所有CN作业算子最近执行资源信息。要查到记录,必须保证resource_track_level为operator。
postgres=# SELECT * FROM pgxc_wlm_operator_history;通过数据表gs_wlm_operator_info查询当前CN作业算子历史执行资源信息。要查到记录,必须保证resource_track_level为operator和enable_resource_record为on。
postgres=# SELECT * FROM gs_wlm_operator_info;通过视图pgxc_wlm_operator_info查询所有CN作业算子历史执行资源信息。要查到记录,必须保证resource_track_level为operator和enable_resource_record为on。
postgres=# SELECT * FROM pgxc_wlm_operator_info;说明:
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69959250/viewspace-3131297/ ,如需转载,请注明出处,否则将追究法律责任。