Last active
September 6, 2021 07:37
-
-
Save nephest/b8c8d91c05fbad9b18df597896787727 to your computer and use it in GitHub Desktop.
Taken from https://stackoverflow.com/questions/12641676/how-to-get-a-status-of-a-running-query-in-postgresql-database, https://stackoverflow.com/questions/35319597/how-to-stop-kill-a-query-in-postgresql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--active query list | |
SELECT datname, pid, state, query, age(clock_timestamp(), query_start) AS age | |
FROM pg_stat_activity | |
WHERE state <> 'idle' | |
AND query NOT LIKE '% FROM pg_stat_activity %' | |
ORDER BY age; | |
--shutdown | |
SELECT pg_cancel_backend(<pid of the process>); | |
--kill | |
SELECT pg_terminate_backend(<pid of the process>); | |
--total relation size | |
SELECT pg_size_pretty(pg_total_relation_size('relation_name')); | |
--relation size | |
SELECT pg_size_pretty(pg_relation_size('relation_name')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment