Book Image

Learning Heroku Postgres

By : Patrick Rafael de Oliveira Espake
Book Image

Learning Heroku Postgres

By: Patrick Rafael de Oliveira Espake

Overview of this book

Table of Contents (17 chapters)
Learning Heroku Postgres
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Keyword List
Index

Automatic vacuuming


The automatic way is the most effective way to ensure the performance of your database. It allows you to configure each table or database so you are informed about when the autovacuum should be performed. For example:

$ heroku pg:psql --app your-app-name
=> ALTER TABLE invitations SET (autovacuum_vacuum_threshold = 60);
=> ALTER TABLE invitations SET (autovacuum_vacuum_scale_factor = 0.4);

The preceding setting sets the time that the autovacuum should run in your table. The threshold value defines the raw number of necessary dead lines and the scale factor defines the bloat factor to run the autovacuum process. The default values for these settings are 50 and 0.2 respectively.

With these two settings you get the real limit through the following formula:

vacuum threshold = autovacuum_vacuum_threshold +     autovacuum_vacuum_scale_factor * number of rows

You can also impose these settings at the database level, through the following settings:

$ heroku pg:psql --app...