切换到postgres用户,执行psql,进入数据库终端:指定上述命令找到的系统进程号
procpid=15874(进程号)
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 procpid=15874
ORDER BY lap DESC;