| From: | Greg Burd <greg(at)burd(dot)me> |
|---|---|
| To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Cc: | Yao Feng <fengyao0087(at)gmail(dot)com>, Peter Geoghegan <pg(at)bowt(dot)ie> |
| Subject: | Re: nbtree: opt-in leaf key prefix compression |
| Date: | 2026-11-13 13:22:38 |
| Message-ID: | avcFtCm7BOZ02kCl@werk |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hello,
v12 attached. While reviewing the code I found two correctness fixes in
the split path, plus a small reentrancy cleanup.
I spotted that the split-fit accounting was off by the item alignment.
The directory caches the decoded size of a coded page's data items, and
the split-fit check uses that cache to decide when a coded page must
split before it can no longer be divided into two plain pages. The
cache was summing the unaligned IndexTupleSize of each decoded item,
while the split itself and the CREATE INDEX fill estimate both reason in
MAXALIGN(IndexTupleSize). So the cache could undercount by up to the
alignment (7 bytes) per item, which is bad but what is fatal is that it
could undercount enough items and the gate could admit an insert onto a
page whose true decoded content no longer fits two plain pages, and the
split would then fail to find a legal point.
Fixed, added an assert to keep me honest in the future (belt and
suspenders).
_bt_compare() and _bt_prefix_try_plain_page() each held their decode
scratch in a static buffer, and because I care about a multi-threaded
future where that could be a problem (hidden process-global state) I
changed that to stack local memory.
As an aside, not really related to this thread... we're going to need
tooling to find existing and prevent future use of this pattern if we're
ever going to transition to a thread-based server.
best.
-greg
| Attachment | Content-Type | Size |
|---|---|---|
| v12-0001-nbtree-opt-in-leaf-key-prefix-compression.patch | application/octet-stream | 177.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Matheus Alcantara | 2026-11-13 13:26:57 | Re: extension_control_path: ignore empty elements and deduplicate directories |
| Previous Message | g l | 2026-11-13 13:19:57 | Re: [BUG] Planner bug causes incorrect query results in PG14 and PG15 |