Re: New IndexAM API controlling index vacuum strategies
Peter Geoghegan <pg@bowt.ie>
From: Peter Geoghegan <pg@bowt.ie>
To: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: Andres Freund <andres@anarazel.de>, Robert Haas <robertmhaas@gmail.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>,
Noah Misch <noah@leadboat.com>
Date: 2021-03-24T01:23:55Z
Lists: pgsql-hackers
On Mon, Mar 22, 2021 at 6:40 AM Masahiko Sawada <sawada.mshk@gmail.com> wrote: > I've looked at this 0001 patch and here are some review comments: > + * Since we might have to prune a second time here, the code is structured to > + * use a local per-page copy of the counters that caller accumulates. We add > + * our per-page counters to the per-VACUUM totals from caller last of all, to > + * avoid double counting. > > Those comments should be a part of 0002 patch? Right -- will fix. > pc.num_tuples is incremented twice. ps->hastup = true is also duplicated. Must have been a mistake when splitting the patch up -- will fix. > --- > In step 7, with the patch, we save the freespace of the page and do > lazy_vacuum_page(). But should it be done in reverse? > How about renaming to vacuum_two_pass_strategy() or something to clear > this function is used to vacuum? Okay. I will rename it to lazy_vacuum_pruned_items(). > vacrelstats->dead_tuples->num_tuples))); > > It seems that the comment needs to be updated. Will fix. > I’ll review the other two patches tomorrow. And I'll respond to your remarks on those (which are already posted now) separately. > I didn't look at the 0002 patch in-depth but the main difference > between those two WAL records is that XLOG_HEAP2_PRUNE has the offset > numbers of unused, redirected, and dead whereas XLOG_HEAP2_VACUUM has > only the offset numbers of unused? That's one difference. Another difference is that there is no latestRemovedXid field. And there is a third difference: we no longer need a super-exclusive lock for heap page vacuuming (not pruning) with this design -- which also means that we cannot defragment the page during heap vacuuming (that's unsafe with only an exclusive lock because it physically relocates tuples with storage that somebody else may have a C pointer to that they expect to stay sane). These differences during original execution of heap page vacuum necessitate inventing a new REDO routine that does things in exactly the same way. To put it another way, heap vacuuming is now very similar to index vacuuming (both are dissimilar to heap pruning). They're very simple, and 100% a matter of freeing space in physical data structures. Clearly that's always something that we can put off if it makes sense to do so. That high level simplicity seems important to me. I always disliked the way the WAL records for vacuumlazy.c worked. Especially the XLOG_HEAP2_CLEANUP_INFO record -- that one is terrible. -- Peter Geoghegan
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Don't truncate heap when VACUUM's failsafe is in effect.
- 60f1f09ff443 14.0 landed
-
Teach VACUUM to bypass unnecessary index vacuuming.
- 5100010ee4d5 14.0 landed
-
Add wraparound failsafe to VACUUM.
- 1e55e7d1755c 14.0 landed
-
Truncate line pointer array during VACUUM.
- 3c3b8a4b2689 14.0 landed
-
Remove tupgone special case from vacuumlazy.c.
- 8523492d4e34 14.0 landed
-
Refactor lazy_scan_heap() loop.
- 7ab96cf6b312 14.0 landed
-
Propagate parallel VACUUM's buffer access strategy.
- 49f49defe7c0 14.0 cited
-
Simplify state managed by VACUUM.
- b4af70cb2103 14.0 landed
-
Notice that heap page has dead items during VACUUM.
- 0ea71c93a06d 14.0 landed
-
Adjust lazy_scan_heap() accounting comments.
- 7cde6b13a9b6 14.0 cited
-
Use full 64-bit XID for checking if a deleted GiST page is old enough.
- 6655a7299d83 13.0 cited
-
Fix some problems with VACUUM (INDEX_CLEANUP FALSE).
- dd6959798885 12.0 cited