如何防止Postgres中表的autovacuum

时间:2014-11-04 19:49:20

标签: postgresql postgresql-9.2 autovacuum

我有大表,我只有插入和选择,所以当这个表的autovacuum运行时 - 系统非常慢。我已关闭特定表的autovacuum:

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);

在此之后(一段时间之后),我看到了:

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)

我做了什么shell来切换这个表的autovacuuming?

1 个答案:

答案 0 :(得分:6)

这里的关键是:

(to prevent wraparound)

这意味着Postgres 必须 autovacuum才能free up transaction identifiers

您不能完全禁用此类型的自动清空,但您可以通过调整autovacuum_freeze_max_agevacuum_freeze_min_age参数来降低其频率。