Re: [HACKERS] [WIP] Effective storage of duplicates in B-tree index.
Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
Attachments
- v19-0001-Add-deduplication-to-nbtree.patch (text/x-patch) patch v19-0001
25.09.2019 22:14, Peter Geoghegan wrote: > >>> We still haven't added an "off" switch to deduplication, which seems >>> necessary. I suppose that this should look like GIN's "fastupdate" >>> storage parameter. >> Why is it necessary to save this information somewhere but rel->rd_options, >> while we can easily access this field from _bt_findinsertloc() and >> _bt_load(). > Maybe, but we also need to access a flag that says it's safe to use > deduplication. Obviously deduplication is not safe for datatypes like > numeric and text with a nondeterministic collation. The "is > deduplication safe for this index?" mechanism will probably work by > doing several catalog lookups. This doesn't seem like something we > want to do very often, especially with a buffer lock held -- ideally > it will be somewhere that's convenient to access. > > Do we want to do that separately, and have a storage parameter that > says "I would like to use deduplication in principle, if it's safe"? > Or, do we store both pieces of information together, and forbid > setting the storage parameter to on when it's known to be unsafe for > the underlying opclasses used by the index? I don't know. > > I think that you can start working on this without knowing exactly how > we'll do those catalog lookups. What you come up with has to work with > that before the patch can be committed, though. > Attached is v19. * It adds new btree reloption "deduplication". I decided to refactor the code and move BtreeOptions into a separate structure, rather than adding new btree specific value to StdRelOptions. Now it can be set even for indexes that do not support deduplication. In that case it will be ignored. Should we add this check to option validation? * By default deduplication is on for non-unique indexes and off for unique ones. * New function _bt_dedup_is_possible() is intended to be a single place to perform all the checks. Now it's just a stub to ensure that it works. Is there a way to extract this from existing opclass information, or we need to add new opclass field? Have you already started this work? I recall there was another thread, but didn't manage to find it. * I also integrated into this version your latest patch that enables deduplication on unique indexes, since now it can be easily switched on/off. -- Anastasia Lubennikova Postgres Professional: http://www.postgrespro.com The Russian Postgres Company
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