I have big tables in which I have only inserts and selects, so when autovacuum for this tables is running - system is very slow. I have switch off autovacuum for specific tables:
ALTER TABLE ag_event_20141004_20141009 SET (autovacuum_enabled = false, toast.autovacuum_enabled = false);
ALTER TABLE ag_event_20141014_20141019 SET (autovacuum_enabled = false, toast.autovacuum_enabled = false);
After this (some time after) I see:
select pid, waiting, xact_start, query_start,query from pg_stat_activity order by query_start;
18092 | f | 2014-11-04 22:21:05.95512+03 | 2014-11-04 22:21:05.95512+03 | autovacuum: VACUUM public.ag_event_20141004_20141009 (to prevent wraparound)
19877 | f | 2014-11-04 22:22:05.889182+03 | 2014-11-04 22:22:05.889182+03 | autovacuum: VACUUM public.ag_event_20141014_20141019 (to prevent wraparound)
What shell I do to switch autovacuuming for this tables at all ??
Autovacuum does take a lock on the table, but it is a weak lock which does not interfere with normal operations (SELECT, UPDATE, DELETE) but will interfere with things like adding indexes, or truncating the table.
Autovacuum may be disabled on certain tables We can re-enable it by running: ALTER TABLE my_table SET (autovacuum_enabled = true);
PostgreSQL has an optional but highly recommended feature called autovacuum, whose purpose is to automate the execution of VACUUM and ANALYZE commands. When enabled, autovacuum checks for tables that have had a large number of inserted, updated or deleted tuples.
Since VACUUM does not take any exclusive lock on tables, it does not (or minimal) impact other database work. The configuration of Auto-VACUUM should be done based on the usage pattern of the database.
The key here is:
(to prevent wraparound)
This means Postgres must autovacuum in order to free up transaction identifiers.
You can not entirely disable this type of autovacuum, but you can reduce its frequency by tuning the autovacuum_freeze_max_age
and vacuum_freeze_min_age
parameters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With