如何查询postgresql 执行过的sql语句
答案:1 悬赏:0 手机版
解决时间 2021-02-12 14:14
- 提问者网友:谁的错
- 2021-02-11 14:22
如何查询postgresql 执行过的sql语句
最佳答案
- 五星知识达人网友:人類模型
- 2021-02-11 15:05
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 <> '<IDLE>'
ORDER BY
lap DESC;
procpid:进程id
start:进程开始时间
lap:经过时间
current_query:执行中的sql
怎样停止正在执行的sql
SELECT pg_cancel_backend(进程id);
或者用系统函数
kill -9 进程id;
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 <> '<IDLE>'
ORDER BY
lap DESC;
procpid:进程id
start:进程开始时间
lap:经过时间
current_query:执行中的sql
怎样停止正在执行的sql
SELECT pg_cancel_backend(进程id);
或者用系统函数
kill -9 进程id;
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯