procpid:进程id 如果不确认进程ID,将上面的条件去掉,可以逐条分析
start:进程开始时间
lap:经过时间
current_query:执行中的sql
怎样停止正在执行的sql :SELECT pg_cancel_backend(进程id);或者select pg_terminate_backend(‘procpid’);
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>' and current_query <>'select 1' and
(current_query like 'select%' or current_query like 'ALTER%')
ORDER BY lap DESC;
SELECT pg_cancel_backend(‘procpid’)
这种方式只能kill select查询,对update、delete 及DML不生效)
SELECT pg_terminate_backend(‘procpid’);
这种可以kill掉各种操作(select、update、delete、drop等)操作
测试测试测试测试测试测试测试测试测试测试测试测试测试测试
48448
测试