简体   繁体   中英

High autovacuum_vacuum_cost_limit - why?

Update 2022-11-10: I have opened a case with AWS for this one and will let you know here once they have responded.

Postgres 12.9 AWS Managed on db.r5.4xlarge which has 64GB RAM.

autovacuum_vacuum_cost_limit is at 1800:

select setting from pg_settings where name = 'autovacuum_vacuum_cost_limit'; -- 1800

Parameter group in AWS Console:

autovacuum_vacuum_cost_limit: GREATEST({log(DBInstanceClassMemory/21474836480)*600},200)

rds.adaptive_autovacuum: 1

Calculation for autovacuum_vacuum_cost_limit IMHO:

64 Gigabytes = 68,719,476,736 Bytes

GREATEST({log(68719476736/21474836480)*600},200)

GREATEST({log(3.2)*600},200)

GREATEST({0.50514997832*600},200)

GREATEST(303.089986992,200)

CloudWatch Metric MaximumUsedTransactionIDs hovers around 200mio. Many tables are close to 200mio.

So autovacuum_vacuum_cost_limit should be 303 IMHO? Why is autovacuum_vacuum_cost_limit at 1800? I would expect 303. I think I can rule out manual intervention. Thank you.

Here is the answer from aws. In short, the explanation is twofold:

  1. by "log" they mean "log base 2" and not "log base 10"
  2. they are rounding at one point
The autovacuum_vacuum_cost_limit formula is GREATEST({log(DBInstanceClassMemory/21474836480)*600},200).

Log in above formula is log of base 2 and the log value is rounded off before it is multiplied by 600.

As your instance's instance type is r5.2xlarge, the instance class memory is 64 gb.

DBInstanceClassMemory= 64 GiB =68719476736 bytes

Therefore, the following calculation is used to calculate the autovacuum_vacuum_cost_limit value:

GREATEST({log(68719476736/21474836480)600},200)
= GREATEST({log(3.2)600},200) --> log base 2 of (3.2) is 1.678 which is rounded off to 2
= GREATEST({2*600},200)
= GREATEST({1200},200)
= 1200

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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