-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
We should add a macrostrat db subcommand to inspect and kill long-running processes. Sometimes, it is useful to understand how our applications are interacting with the database.
As a starting point, we can wrap queries like this:
-- Describe all long-running processes
SELECT
datname,
pid,
state,
query,
age(clock_timestamp(), query_start) AS duration
FROM
pg_stat_activity
WHERE
state <> 'idle'
AND query NOT ILIKE '%pg_stat_activity%'
AND pid <> pg_backend_pid()
ORDER BY
duration DESC;
-- Terminate a specific query by PID
SELECT pg_terminate_backend(2121843);Reactions are currently unavailable