Add an entry about VACUUM FULL to Maintenance docs (#3348)

This commit is contained in:
Matjaž Horvat 2024-09-17 21:26:52 +02:00 коммит произвёл GitHub
Родитель ff2c4d0246
Коммит d679904f5c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 39 добавлений и 0 удалений

Просмотреть файл

@ -54,3 +54,42 @@ and add them to the BLOCKED_IPs config variable in Heroku Settings.
.. _DDoS: https://en.wikipedia.org/wiki/Denial-of-service_attack
.. _IP detection script: https://github.com/mozilla-l10n/pontoon-scripts/blob/main/dev/check_ips_heroku_log.py
Vacuuming a Database
--------------------
To reduce the size of Postgres DB tables and improve performance, it is recommended to
`vacuum the database`_ regularly. Heroku already does that partially by running the
`VACUUM` command automatically, but that only marks the space as available for reuse.
Running `VACUUM FULL` offers a more exhaustive cleanup and reduces bloat.
.. Warning::
`VACUUM FULL` is a heavyweight operation, which prevents any other statements from
running concurrently, even simple SELECT queries. For most tables it only takes a
few seconds to complete, but on the bigger tables it can take up to a few minutes.
During that time, the application will be unresponsive.
You can run `VACUUM FULL` with the following command:
.. code-block:: bash
$ heroku pg:psql --app mozilla-pontoon
=> VACUUM FULL table_name;
To list the DB tables, ordered by size, run:
.. code-block:: bash
$ heroku pg:psql --app mozilla-pontoon
=> SELECT
table_name,
pg_size_pretty(pg_total_relation_size(table_name::text)) AS size
FROM
information_schema.tables
WHERE
table_schema = 'public'
ORDER BY
pg_total_relation_size(table_name::text) DESC;
.. _vacuum the database: https://devcenter.heroku.com/articles/managing-vacuum-on-heroku-postgres