4

We have a very large table that was partitioned into monthly tables. We have no autovacuum parameters set in the postgresql.conf file, so it's on by default with default parameters.

The past months tables table_201404, table_201403 do not get written to or updated/deleted once they are passed, they are only read from for historical data. Why is it that we are noticing autovacuum processes running on these tables? Is it because they are part of a main partition and PostgreSQL is seeing those tables as one?

We are toying with the idea of setting autovacuum_enabled to off for these past tables, but I wanted to consult the wisdom of Stackoverflow first.

Thanks all...

4

1 回答 1

5

即使是只读表也需要每 20 亿个事务清空一次回卷,并且在默认设置下每 1.5 亿个事务清空一次回卷。

每行存储的事务 ID 为 32 位,因此它们最终会回绕。为了防止这引起问题,任何非常旧的 transactionID 都必须替换为一个魔术值,意思是“比所有其他 ID 都旧”。所以必须扫描表才能进行替换。如果表永远不会改变,最终每个事务 ID 都将被替换为魔法值,并且从概念上讲,该表不再需要被扫描。但是这个事实并没有存储在任何地方,所以仍然需要时不时地扫描表,以便系统可以观察到它们都还可以。幸运的是,扫描是按顺序完成的,只需要读取而不是写入,因此应该相当有效。

整个事情可能会在 9.5 中重做,这样就不再需要扫描这样的表了。

于 2014-05-08T17:18:05.363 回答