简体   繁体   English

Postgresql:Autovacuum分区表

[英]Postgresql: Autovacuum partitioned tables

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. 我们在postgresql.conf文件中没有设置autovacuum参数,因此默认情况下它使用默认参数。

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. 过去几个月表table_201404,table_201403一旦传递就不会被写入或更新/删除,它们只会从历史数据中读取。 Why is it that we are noticing autovacuum processes running on these tables? 为什么我们注意到在这些表上运行的autovacuum进程? Is it because they are part of a main partition and PostgreSQL is seeing those tables as one? 是因为它们是主分区的一部分而PostgreSQL将这些表视为一个?

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. 我们正在考虑将autovacuum_enabled设置为关闭这些过去的表,但我想先咨询Stackoverflow的智慧。

Thanks all... 谢谢大家......

Even read-only tables need to be vacuumed for wrap-around once every 2 billion transactions, and under the default settings are vacuumed for wrap-around once every 150 million transactions. 甚至只读表需要对每20亿次事务进行一次真空吸尘,并且在默认设置下进行抽真空以便每1.5亿次交易进行一次环绕。

The transaction IDs stored with each row are 32 bits, so they wrap around eventually. 每行存储的事务ID是32位,因此它们最终会回绕。 To prevent this from causing problems, any very old transactionID has to be replaced with a magic value meaning "Older than all other IDs". 为了防止这种情况造成问题,任何非常旧的transactionID都必须替换为魔术值,意思是“比所有其他ID更旧”。 So the table has to be scanned to do that replacement. 因此必须扫描该表以进行替换。 If the table never changes, eventually every transaction ID will be replaced with the magic value and conceptually that table no longer needs to be scanned. 如果表永远不会更改,最终每个事务ID都将替换为魔术值,并且概念上不再需要扫描该表。 But that fact is not stored anywhere, so the table still needs to be scanned every now then so that the system can observe that they are all still OK. 但是这个事实并没有存储在任何地方,所以现在仍需要对表进行扫描,以便系统能够观察到它们仍然可以正常运行。 Fortunately the scan is done in sequentially and only needs to read, not write, so it should be fairly efficient. 幸运的是,扫描是按顺序完成的,只需要读取,而不是写入,因此它应该相当有效。

It is possible that the whole thing will be redone in 9.5 so that tables like that would no longer need to be scanned. 整个事情可能会在9.5中重做,因此不再需要扫描这样的表格。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM