Last active
January 2, 2016 17:39
-
-
Save teeparham/8337894 to your computer and use it in GitHub Desktop.
Check postgres disk usage and vacuum
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
# TL/DR; run `vacuum full` on your postgres databases | |
# auto-vacuuming is on by default but the thresholds are fairly high | |
http://www.postgresql.org/docs/9.3/static/sql-vacuum.html | |
http://www.postgresql.org/docs/9.3/static/routine-vacuuming.html | |
# ---> autovacuum & track_counts are on by default. In postgresql.conf: | |
# track_counts = on | |
# autovacuum = on | |
# ---> Manually check disk space & run vacuum: | |
$ cd /usr/local/pgsql/data/base | |
$ du -sh * | sort -n | tail -3 | |
39M 75256 | |
132M 22665 | |
2.6G 26315 # <-- this one is huge! | |
# What database is 26315? | |
$ oid2name | grep 26315 | |
26315 neighborland_development pg_default | |
$ psql -d neighborland_development | |
neighborland_development=# vacuum full; | |
VACUUM | |
Time: 16985.289 ms | |
neighborland_development=# \q | |
$ du -sh * | sort -n | |
... | |
180M 26315 # <-- 2.6G to 180M ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment