Last active
August 23, 2018 13:33
-
-
Save jpbruinsslot/e3842793d25d9f6320dd9eb0c150bc5a to your computer and use it in GitHub Desktop.
Close postgres idle connection
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
| -- Get pid | |
| SELECT | |
| pid | |
| ,datname | |
| ,usename | |
| ,application_name | |
| ,client_hostname | |
| ,client_port | |
| ,backend_start | |
| ,query_start | |
| ,query | |
| FROM pg_stat_activity | |
| WHERE state <> 'idle' | |
| AND pid<>pg_backend_pid(); | |
| -- Close pid | |
| SELECT pg_terminate_backend(PID); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment