PostgreSQL列舉正在執(zhí)行中的sql
1.SELECT
2. procpid,
3. start,
4. now() - start AS lap,
5. current_query
6.FROM
7. (SELECT
8. backendid,
9. pg_stat_get_backend_pid(S.backendid) AS procpid,
10. pg_stat_get_backend_activity_start(S.backendid) AS start,
11. pg_stat_get_backend_activity(S.backendid) AS current_query
12. FROM
13. (SELECT pg_stat_get_backend_idset() AS backendid) AS S
14. ) AS S
15.WHERE
16. current_query <> '<IDLE>' 17.ORDER BY
18. lap DESC;
procpid:進程id
start:進程開始時間
lap:經(jīng)過時間
current_query:執(zhí)行中的sql
怎樣停止正在執(zhí)行的sql
SELECT pg_cancel_backend(進程id);
或者用系統(tǒng)函數(shù)
kill -9 進程id; 本文出自:億恩科技【1tcdy.com】
服務(wù)器租用/服務(wù)器托管中國五強!虛擬主機域名注冊頂級提供商!15年品質(zhì)保障!--億恩科技[ENKJ.COM]
|