Last active
April 3, 2018 17:23
-
-
Save stevenharman/6535482 to your computer and use it in GitHub Desktop.
View open connections to a PostgreSQL 9.2+ database. Quite useful when you're seeing ActiveRecord::ConnectionTimeoutError on Heroku.
This file contains 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
-- On Heroku: | |
-- $ heroku pg:psql | |
-- An explaination of the columns on the pg_stat_activity table: | |
-- http://www.postgresql.org/docs/9.2/static/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW | |
select | |
pid, application_name, query, waiting, state, state_change | |
from pg_stat_activity | |
where usename = current_user | |
order by state_change desc; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also this:
https://github.com/heroku/heroku-pg-extras