postgres - 列出耗时进程,干掉进程,以及$1的使用 list process list , stop process
访问量: 550
refer to:
https://www.sqlprostudio.com/blog/8-killing-cancelling-a-long-running-postgres-query
列出进程:
https://josuamarcelc.com/show-full-processlist-in-postgresql/
SELECT user, pid, client_addr, query, query_start, NOW() - query_start AS elapsed FROM pg_stat_activity WHERE query != '' -- AND EXTRACT(EPOCH FROM (NOW() - query_start)) > 1 ORDER BY elapsed DESC;
干掉进程:
Option #1 (graceful):
SELECT pg_cancel_backend(<PID>);
Option #2 (forceful):
SELECT pg_terminate_backend(<PID>);
列出index:
\d your_table_name