Re: [HACKERS] [WIP] Effective storage of duplicates in B-tree index.
Peter Geoghegan <pg@bowt.ie>
Attachments
- v13-0002-Stop-deduplicating-when-a-page-split-is-avoided.patch (application/octet-stream) patch v13-0002
- v13-0003-DEBUG-Add-pageinspect-instrumentation.patch (application/octet-stream) patch v13-0003
- v13-0001-Add-deduplication-to-nbtree.patch (application/octet-stream) patch v13-0001
On Wed, Sep 11, 2019 at 2:04 PM Peter Geoghegan <pg@bowt.ie> wrote: > I think that the new WAL record has to be created once per posting > list that is generated, not once per page that is deduplicated -- > that's the only way that I can see that avoids a huge increase in > total WAL volume. Even if we assume that I am wrong about there being > value in making deduplication incremental, it is still necessary to > make the WAL-logging behave incrementally. Attached is v13 of the patch, which shows what I mean. You could say that v13 makes _bt_dedup_one_page() do a few extra things that are kind of similar to the things that nbtsplitloc.c does for _bt_split(). More specifically, the v13-0001-* patch includes code that makes _bt_dedup_one_page() "goal orientated" -- it calculates how much space will be freed when _bt_dedup_one_page() goes on to deduplicate those items on the page that it has already "decided to deduplicate". The v13-0002-* patch makes _bt_dedup_one_page() actually use this ability -- it makes _bt_dedup_one_page() give up on deduplication when it is clear that the items that are already "pending deduplication" will free enough space for its caller to at least avoid a page split. This revision of the patch doesn't truly make deduplication incremental. It is only a proof of concept that shows how _bt_dedup_one_page() can *decide* that it will free "enough" space, whatever that may mean, so that it can finish early. The task of making _bt_dedup_one_page() actually avoid lots of work when it finishes early remains. As I said yesterday, I'm not asking you to accept that v13-0002-* is an improvement. At least not yet. In fact, "finishes early" due to the v13-0002-* logic clearly makes everything a lot slower, since _bt_dedup_one_page() will "thrash" even more than earlier versions of the patch. This is especially problematic with WAL-logged relations -- the test case that I shared yesterday goes from about 6GB to 10GB with v13-0002-* applied. But we need to fundamentally rethink the approach to the rewriting + WAL-logging by _bt_dedup_one_page() anyway. (Note that total index space utilization is barely affected by the v13-0002-* patch, so clearly that much works well.) Other changes: * Small tweaks to amcheck (nothing interesting, really). * Small tweaks to the _bt_killitems() stuff. * Moved all of the deduplication helper functions to nbtinsert.c. This is where deduplication gets complicated, so I think that it should all live there. (i.e. nbtsort.c will call nbtinsert.c code, never the other way around.) Note that I haven't merged any of the changes from v12 of the patch from yesterday. I didn't merge the posting list WAL logging changes because of the bug I reported, but I would have were it not for that. The WAL logging for _bt_dedup_one_page() added to v12 didn't appear to be more efficient than your original approach (i.e. calling log_newpage_buffer()), so I have stuck with your original approach. It would be good to hear your thoughts on this _bt_dedup_one_page() WAL volume/"write amplification" issue. -- Peter Geoghegan
Commits
-
Teach pageinspect about nbtree deduplication.
- 93ee38eade1b 13.0 landed
-
Doc: Fix deduplicate_items index term.
- e537aed61db7 13.0 landed
-
Revise BTP_HAS_GARBAGE nbtree VACUUM comments.
- 4b25f5d0ba01 13.0 cited
-
Remove unneeded "pin scan" nbtree VACUUM code.
- 9f83468b3536 13.0 landed
-
Cleanup code in reloptions.h regarding reloption handling
- 50d22de9325f 13.0 cited
-
Catch invalid typlens in a couple of places
- 8557a6f10ca6 13.0 cited
-
Compute XID horizon for page level index vacuum on primary.
- 558a9165e081 12.0 cited
-
Make heap TID a tiebreaker nbtree index column.
- dd299df8189b 12.0 cited
-
Avoid pin scan for replay of XLOG_BTREE_VACUUM in all cases
- 3e4b7d87988f 9.6.0 cited
-
Revert buggy optimization of index scans
- c7111d11b188 9.6.0 cited
-
Restructure index access method API to hide most of it at the C level.
- 65c5fcd353a8 9.6.0 cited
-
Reduce pinning and buffer content locking for btree scans.
- 2ed5b87f96d4 9.5.0 cited
-
Avoid scanning nulls at the beginning of a btree index scan.
- 1a77f8b63d15 9.2.0 cited