Created
December 6, 2025 09:44
-
-
Save repodevs/b8b57350bd4a0c84539c8bbe628c6c7f to your computer and use it in GitHub Desktop.
watch command to run postgres query every 1 seconds via psql
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 count postgres idle connection for database | |
| $ watch -n 1 psql -U myuser -d mydb -c \"select count\(\*\) from pg_stat_activity where state in \(\'idle\', \'idle in transaction\'\) and datname = \'mydb\'\" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment