Bobochka
5/18/2017 - 5:26 PM

Postgres query list and kill query

Postgres query list and kill query

SELECT
  pid,
  now() — pg_stat_activity.query_start AS duration,
  query,
  state
FROM pg_stat_activity
WHERE now() — pg_stat_activity.query_start > interval '5 minutes';

SELECT pg_cancel_backend(__pid__);