Last active
January 26, 2018 07:33
-
-
Save tyagiakhilesh/747cf2471fd1e66c629fda127ae774e6 to your computer and use it in GitHub Desktop.
Postgres maintainance queries
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
-- Finding open connections | |
SELECT * FROM pg_stat_activity; | |
-- Dropping open connections | |
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = <databasename> AND pid <> pg_backend_pid() AND state in ( 'idle'); | |
-- Describing a table | |
select column_name, data_type, character_maximum_length from INFORMATION_SCHEMA.COLUMNS where table_name = 'pg_stat_activity'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment