Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
postgresql_management [2024/07/17 20:06] – [VACUUMING] andonovj | postgresql_management [2024/07/18 04:41] (current) – [VACUUMING] andonovj | ||
---|---|---|---|
Line 467: | Line 467: | ||
=====VACUUMING===== | =====VACUUMING===== | ||
- | VACUUM Tips and Best Practices | ||
- | Tried and tested tips and best practices for PostgreSQL vacuuming | ||
Vacuuming should be part of routine database maintenance, | Vacuuming should be part of routine database maintenance, | ||
Don’t run manual VACUUM or ANALYZE without reason. | Don’t run manual VACUUM or ANALYZE without reason. | ||
Line 504: | Line 502: | ||
ALTER TABLE < | ALTER TABLE < | ||
- | | + | Fine-tune Autovacuum workers |
Another parameter often overlooked is autovacuum_max_workers, | Another parameter often overlooked is autovacuum_max_workers, | ||
A common practice by PostgreSQL DBAs is to increase the number of maximum worker threads to speed up autovacuum. This doesn’t work as all the threads share the same autovacuum_vacuum_cost_limit, | A common practice by PostgreSQL DBAs is to increase the number of maximum worker threads to speed up autovacuum. This doesn’t work as all the threads share the same autovacuum_vacuum_cost_limit, | ||
Line 522: | Line 520: | ||
A better way is to tune these parameters for individual tables only when necessary. For example, if the autovacuum of a large transactional table is taking too long, the table may be temporarily configured to use its own vacuum cost limit and cost delays. The cost limit and delay will override the system-wide values set in postgresql.conf. | A better way is to tune these parameters for individual tables only when necessary. For example, if the autovacuum of a large transactional table is taking too long, the table may be temporarily configured to use its own vacuum cost limit and cost delays. The cost limit and delay will override the system-wide values set in postgresql.conf. | ||
The code snippet below shows how to configure individual tables. | The code snippet below shows how to configure individual tables. | ||
- | ALTER TABLE < | + | |
- | ALTER TABLE < | + | * ALTER TABLE < |
+ | | ||
Using the first parameter will ensure the autovacuum thread assigned to the table performs more work before going to sleep. Lowering the autovacuum_vacuum_cost_delay will also mean the thread sleeps for less time. | Using the first parameter will ensure the autovacuum thread assigned to the table performs more work before going to sleep. Lowering the autovacuum_vacuum_cost_delay will also mean the thread sleeps for less time. | ||
Get more best practice tips from our professional team of PostgreSQL experts: | Get more best practice tips from our professional team of PostgreSQL experts: | ||
===Examples=== | ===Examples=== |