Re: [WIP] Effective storage of duplicates in B-tree index.
Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
Attachments
- btc_readme_1.0.patch (text/x-patch)
- btree_compression_3.0.patch (text/x-patch) patch
04.02.2016 20:16, Peter Geoghegan:
> On Fri, Jan 29, 2016 at 8:50 AM, Anastasia Lubennikova
> <a.lubennikova@postgrespro.ru> wrote:
>> I fixed it in the new version (attached).
Thank you for the review.
At last, there is a new patch version 3.0. After some refactoring it
looks much better.
I described all details of the compression in this document
https://goo.gl/50O8Q0
<https://vk.com/away.php?to=https%3A%2F%2Fgoo.gl%2F50O8Q0> (the same
text without pictures is attached in btc_readme_1.0.txt).
Consider it as a rough copy of readme. It contains some notes about
tricky moments of implementation and questions about future work.
Please don't hesitate to comment it.
> Some quick remarks on your V2.0:
>
> * Seems unnecessary that _bt_binsrch() is passed a real pointer by all
> callers. Maybe the one current posting list caller
> _bt_findinsertloc(), or its caller, _bt_doinsert(), should do this
> work itself:
>
> @@ -373,7 +377,17 @@ _bt_binsrch(Relation rel,
> * scan key), which could be the last slot + 1.
> */
> if (P_ISLEAF(opaque))
> + {
> + if (low <= PageGetMaxOffsetNumber(page))
> + {
> + IndexTuple oitup = (IndexTuple) PageGetItem(page,
> PageGetItemId(page, low));
> + /* one excessive check of equality. for possible posting
> tuple update or creation */
> + if ((_bt_compare(rel, keysz, scankey, page, low) == 0)
> + && (IndexTupleSize(oitup) + sizeof(ItemPointerData) <
> BTMaxItemSize(page)))
> + *updposing = true;
> + }
> return low;
> + }
>
> * ISTM that you should not use _bt_compare() above, in any case. Consider this:
>
> postgres=# select 5.0 = 5.000;
> ?column?
> ──────────
> t
> (1 row)
>
> B-Tree operator class indicates equality here. And yet, users will
> expect to see the original value in an index-only scan, including the
> trailing zeroes as they were originally input. So this should be a bit
> closer to HeapSatisfiesHOTandKeyUpdate() (actually,
> heap_tuple_attr_equals()), which looks for strict binary equality for
> similar reasons.
Thank you for the notice. Fixed.
> * Is this correct?:
>
> @@ -555,7 +662,9 @@ _bt_buildadd(BTWriteState *wstate, BTPageState
> *state, IndexTuple itup)
> * it off the old page, not the new one, in case we are not at leaf
> * level.
> */
> - state->btps_minkey = CopyIndexTuple(oitup);
> + ItemId iihk = PageGetItemId(opage, P_HIKEY);
> + IndexTuple hikey = (IndexTuple) PageGetItem(opage, iihk);
> + state->btps_minkey = CopyIndexTuple(hikey);
>
> How this code has changed from the master branch is not clear to me.
Yes, it is. I completed the comment above.
> I understand that this code in incomplete/draft:
>
> +#define MaxPackedIndexTuplesPerPage \
> + ((int) ((BLCKSZ - SizeOfPageHeaderData) / \
> + (sizeof(ItemPointerData))))
>
> But why is it different to the old (actually unchanged)
> MaxIndexTuplesPerPage? I would like to see comments explaining your
> understanding, even if they are quite rough. Why did GIN never require
> this change to a generic header (itup.h)? Should such a change live in
> that generic header file, and not another one more localized to
> nbtree?
I agree.
--
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