Skip to content

Instantly share code, notes, and snippets.

@stevenharman
Last active April 3, 2018 17:23
Show Gist options
  • Save stevenharman/6535482 to your computer and use it in GitHub Desktop.
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.
-- 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;
@brandon-beacher
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment