Re: New strategies for freezing, advancing relfrozenxid early
Peter Geoghegan <pg@bowt.ie>
From: Peter Geoghegan <pg@bowt.ie>
To: Matthias van de Meent <boekewurm+postgres@gmail.com>
Cc: John Naylor <john.naylor@enterprisedb.com>,
Jeff Davis <pgsql@j-davis.com>, Andres Freund <andres@anarazel.de>, Justin Pryzby <pryzby@telsasoft.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2022-12-15T18:53:04Z
Lists: pgsql-hackers
On Thu, Dec 15, 2022 at 6:50 AM Matthias van de Meent <boekewurm+postgres@gmail.com> wrote: > This first run of (auto)vacuum after the 8GB threshold seems > to appear as a significant IO event (both in WAL and relation > read/write traffic) with 50% of the table updated and WAL-logged. I > think this should be limited to some degree, such as only freeze > all_visible blocks up to 10% of the table's blocks in eager vacuum, so > that the load is spread across a larger time frame and more VACUUM > runs. I agree that the burden of catch-up freezing is excessive here (in fact I already wrote something to that effect on the wiki page). The likely solution can be simple enough. In v9 of the patch, we switch over to eager freezing when table size crosses 4GB (since that is the value of the vacuum_freeze_strategy_threshold GUC). The catch up freezing that you draw attention to here occurs when table size exceeds 8GB, which is a separate physical table size threshold that forces eager relfrozenxid advancement. The second threshold is hard-coded to 2x the first one. I think that this issue can be addressed by making the second threshold 4x or even 8x vacuum_freeze_strategy_threshold, not just 2x. That would mean that we'd have to freeze just as many pages whenever we did the catch-up freezing -- so no change in the added *absolute* cost of freezing. But, the *relative* cost would be much lower, simply because catch-up freezing would take place when the table was much larger. So it would be a lot less noticeable. Note that we might never reach the second table size threshold before we must advance relfrozenxid, in any case. The catch-up freezing might actually take place because table age created pressure to advance relfrozenxid. It's useful to have a purely physical/table-size threshold like this, especially in bulk loading scenarios. But it's not like table age doesn't have any influence at all, anymore. The cost model weighs physical units/costs as well as table age, and in general the most likely trigger for advancing relfrozenxid is usually some combination of the two, not any one factor on its own [1]. [1] https://wiki.postgresql.org/wiki/Freezing/skipping_strategies_patch:_motivating_examples#Opportunistically_advancing_relfrozenxid_with_bursty.2C_real-world_workloads -- Peter Geoghegan
Commits
-
Revert "Add eager and lazy freezing strategies to VACUUM."
- 6c6b49726644 16.0 landed
-
Add eager and lazy freezing strategies to VACUUM.
- 4d4179926139 16.0 landed
-
Refine the definition of page-level freezing.
- b37a08323964 16.0 landed
-
Avoid special XID snapshotConflictHorizon values.
- 6daeeb1f9196 16.0 cited
-
Add page-level freezing to VACUUM.
- 1de58df4fec7 16.0 landed
-
Remove overzealous MultiXact freeze assertion.
- 63c844a0a5d7 16.0 landed
-
Refactor how VACUUM passes around its XID cutoffs.
- 4ce3afb82ecf 16.0 landed
-
Deduplicate freeze plans in freeze WAL records.
- 9e5405993c1e 16.0 cited
-
Set relfrozenxid to oldest extant XID seen by VACUUM.
- 0b018fabaaba 15.0 cited
-
Only skip pages marked as clean in the visibility map, if the last 32
- bf136cf6e376 8.4.0 cited
-
Add vacuum_freeze_table_age GUC option, to control when VACUUM should
- 6587818542e7 8.4.0 cited