pg_stat_get_backend_activity()

报告后端最近查询的函数

pg_stat_get_backend_activity() 是一个系统函数,用于报告后端最近的查询文本。

pg_stat_get_backend_activity()PostgreSQL 7.2 中添加。

用法

pg_stat_get_backend_activity ( integer ) → text

后端由 pg_stat_get_backend_idset() 报告的后端 ID 号指定;请参阅下面的执行示例。

pg_stat_get_backend_activity_start() 返回的值对应于 pg_stat_activity 中的 query 列(PostgreSQL 9.1 及更早版本:current_query)。

以下相关函数也可用:

更改历史

示例

pg_stat_get_backend_activity_start() 的基本用法示例

postgres=# SELECT pg_stat_get_backend_pid(s.backendid) AS pid,
                  pg_stat_get_backend_activity(s.backendid) AS query
             FROM (SELECT pg_stat_get_backend_idset() AS backendid) AS s;
   pid   |                              query                           
---------+-----------------------------------------------------------------
 1451980 | 
 1451982 | 
 2072322 | SELECT pg_stat_get_backend_pid(s.backendid) AS pid,            +
         |        pg_stat_get_backend_activity(s.backendid) AS query_start+
         |   FROM (SELECT pg_stat_get_backend_idset() AS backendid) AS s;
 1764534 | SELECT pg_stat_get_backend_pid(s.backendid) AS pid             +
         |   FROM (SELECT pg_stat_get_backend_idset() AS backendid) AS s;
 1451978 | 
 1451977 | 
 1451979 | 
(7 rows)

分类

系统函数

另请参阅

pg_stat_activity

反馈

提交关于 "pg_stat_get_backend_activity()" 的任何评论、建议或更正 此处