Database Reference
In-Depth Information
Manual vacuuming
Before running
VACUUM
, it is important for you to understand that there are two main dif-
ferences between the
VACUUM
command (without parameters) and
VACUUM FULL
.
The
VACUUM
command (without parameters) only removes tuples marked as useless in
UPDATE
or
DELETE
processes, so it is unnecessary to lock the database for operations. On
the other hand, the
VACUUM FULL
command also removes the tuples marked as useless
and it organizes the tables, removing empty gaps. To perform this process, it is necessary to
lock the database in order to guarantee that no other action will be taken.
To run the
VACUUM
command, open the
psql
connection through the
heroku
pg:psql
command:
$ heroku pg:psql --app your-app-name
=> VACUUM;
You should also run the
VACUUM
command in a specific table:
$ heroku pg:psql --app your-app-name
=> VACUUM invitations;
If you want to see information during the
VACUUM
process, you can add the
VERBOSE
parameter:
$ heroku pg:psql --app your-app-name
=> VACUUM VERBOSE;
Although you have the freedom to perform the
VACUUM
command on Heroku Postgres, it
is rarely necessary to do it manually. All this can be done automatically if you configure
your database properly, as it will be discussed in the upcoming section.