Skip to content

Instantly share code, notes, and snippets.

@ritec
Last active March 8, 2018 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ritec/6a8031fb27ea8bf8561eec8c00db8037 to your computer and use it in GitHub Desktop.
Save ritec/6a8031fb27ea8bf8561eec8c00db8037 to your computer and use it in GitHub Desktop.
usefulPostgresInfo.sql
# Get a DB Console.
bundle exec rails dbconsole
# Get number of Connections / Used and left
select max_conn,used,res_for_super,max_conn-used-res_for_super res_for_normal
from
(select count(*) used from pg_stat_activity) t1,
(select setting::int res_for_super from pg_settings where name=$$superuser_reserved_connections$$) t2,
(select setting::int max_conn from pg_settings where name=$$max_connections$$) t3
;
# Restart Postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log restart
# Postgres Config Location in OSX
/usr/local/var/postgres/postgresql.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment