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()
pg_stat_get_backend_client_addr()
pg_stat_get_backend_client_port()
pg_stat_get_backend_dbid()
pg_stat_get_backend_pid()
pg_stat_get_backend_start()
pg_stat_get_backend_userid()
pg_stat_get_backend_wait_event()
pg_stat_get_backend_wait_event_type()
pg_stat_get_backend_xact_start()
更改历史
- PostgreSQL 7.2
- 添加(提交 140ddb78)
示例
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)
参考文献
- PostgreSQL 文档: 每个后端统计函数