最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
PostgreSQL查看正在执行的任务并强制结束操作方法代码
时间:2022-06-29 08:46:27 编辑:袖梨 来源:一聚教程网
本篇文章小编给大家分享一下PostgreSQL查看正在执行的任务并强制结束操作方法代码,文章代码介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。
查看任务sql语句:
SELECT
procpid,
start,
now() - start AS lap,
current_query
FROM
(SELECT
backendid,
pg_stat_get_backend_pid(S.backendid) AS procpid,
pg_stat_get_backend_activity_start(S.backendid) AS start,
pg_stat_get_backend_activity(S.backendid) AS current_query
FROM
(SELECT pg_stat_get_backend_idset() AS backendid) AS S
) AS S
WHERE
current_query <> ''
ORDER BY
lap DESC;
其中
procpid:进程id
start:进程开始时间
lap:经过时间
current_query:执行中的sql
强制停止某一个任务:
SELECT pg_cancel_backend(进程id);
补充:
SELECT pid, datname AS db, query_start AS start, now() - query_start AS lap, query FROM pg_stat_activity WHERE state <> 'idle' and query not like '%pg_stat_activity%' and (now() - query_start) > interval '10 seconds';
相关文章
- 三国志8重制版虚构特典剧本介绍说明 10-30
- 暗喻幻想暗黑法师解锁方法攻略分享 10-30
- 暗喻幻想元素大师解锁方法攻略分享 10-30
- 暗喻幻想地下纳骨堂锁住的门打开方法 10-30
- 暗喻幻想6月22日玛丽亚位置一览 10-30
- 暗喻幻想巫师阿基态解锁方法分享 10-30