Re: Deleting older versions in unique indexes to avoid page splits
Peter Geoghegan <pg@bowt.ie>
From: Peter Geoghegan <pg@bowt.ie>
To: Simon Riggs <simon@2ndquadrant.com>
Cc: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Victor Yegorov <vyegorov@gmail.com>
Date: 2020-11-09T17:20:50Z
Lists: pgsql-hackers
Attachments
- v7-0004-Teach-heapam-to-support-bottom-up-index-deletion.patch (application/octet-stream) patch v7-0004
- v7-0002-Pass-down-logically-unchanged-index-hint.patch (application/octet-stream) patch v7-0002
- v7-0003-Teach-nbtree-to-use-bottom-up-index-deletion.patch (application/octet-stream) patch v7-0003
- v7-0001-Make-tableam-interface-support-bottom-up-deletion.patch (application/octet-stream) patch v7-0001
On Tue, Nov 3, 2020 at 12:44 PM Peter Geoghegan <pg@bowt.ie> wrote: > v6 still needs more polishing -- my focus has still been on the > algorithm itself. But I think I'm almost done with that part -- it > seems unlikely that I'll be able to make any additional significant > improvements in that area after v6. Attached is v7, which tidies everything up. The project is now broken up into multiple patches, which can be committed separately. Every patch has a descriptive commit message. This should make it a lot easier to review. I've renamed the feature to "bottom-up index deletion" in this latest revision. This seems like a better name than "dedup deletion". This name suggests that the feature complements "top-down index deletion" by VACUUM. This name is descriptive of what the new mechanism is supposed to do at a high level. Other changes in v7 include: * We now fully use the tableam interface -- see the first patch. The bottom-up index deletion API has been fully worked out. There is now an optional callback/shim function. The bottom-up index deletion caller (nbtree) is decoupled from the callee (heapam) by the tableam shim. This was what allowed me to break the patch into multiple pieces/patches. * The executor no longer uses a IndexUniqueCheck-enum-constant as a hint to nbtree. Rather, we have a new aminsert() bool argument/flag that hints to the index AM -- see the second patch. To recap, the hint tells nbtree that the incoming tuple is a duplicate of an existing tuple caused by an UPDATE, without any logical changes for the indexed columns. Bottom-up deletion is effective when there is a local concentration of these index tuples that become garbage quickly. A dedicated aminsert() argument seems a lot cleaner. Though I wonder if this approach can be generalized a bit further, so that we can support other similar aminsert() hints in the future without adding even more arguments. Maybe some new enum instead of a boolean? * Code cleanup for the nbtdedup.c changes. Better explanation of when and how posting list TIDs are marked promising, and why. * Streamlined handling of the various strategies that nbtinsert.c uses to avoid a page split (e.g. traditional LP_DEAD deletion, deduplication). A new unified function in nbtinsert.c was added. This organization is a lot cleaner -- it greatly simplifies _bt_findinsertloc(), which became more complicated than it really needed to be due to the changes needed for deduplication in PostgreSQL 13. This change almost seems like an independently useful piece of work. -- 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 →
-
Enhance nbtree index tuple deletion.
- d168b666823b 14.0 landed
-
Pass down "logically unchanged index" hint.
- 9dc718bdf2b1 14.0 landed
-
Fix index deletion latestRemovedXid bug.
- 422881744997 14.0 cited
-
Deprecate nbtree's BTP_HAS_GARBAGE flag.
- cf2acaf4dcb5 14.0 landed