| From: | Ethan Tran <ethantran(at)quwin(dot)dev> |
|---|---|
| To: | Andrey Borodin <x4mmm(at)yandex-team(dot)ru> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com> |
| Subject: | Re: [WiP] GiST intrapage indexing |
| Date: | 2026-12-01 16:42:40 |
| Message-ID: | 6BA807D4-3E33-4975-A90F-E56EFB01BFEA@quwin.dev |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Andrey,
I looked at v3 of this patch, focusing on the skiptuple
representation and its performance tradeoffs. I also noted two
implementation/testing issues.
==Patch summary==
My understanding is that each ordinary internal GiST tuple contains a
summary key and a downlink to a child page:
[A] [B] [C] [D] [E] [F]
The patch adds skiptuples that summarize groups of the following
downlinks:
[Summary A-C] [A] [B] [C] [Summary D-F] [D] [E] [F]
A scan can check the group summary first and skip the following members
when the group cannot match. The key idea is to use one consistency
check to avoid several individual checks.
==Design==
> I would rather first hear whether the representation - derived metadata carried in
> ordinary tuple space, with the invalid block number as marker - looks
> acceptable, since everything else depends on that.
The representation looks reasonable to me. Skiptuples use ordinary
index-tuple storage, reusing existing tuple-handling and WAL machinery,
with InvalidBlockNumber marking them as group summaries. Removing them
leaves a valid ordinary GiST page with the same real downlinks.
Maintaining the groups adds work, but the observed performance and WAL
tradeoffs support pursuing this design.
> Group size is a hardcoded 16 and was not tuned.
Currently, the implementation uses a maximum of 16 members per group,
which I find acceptable. Larger groups reduce the number of skiptuples,
but makes group rewrites larger. Initial testing for group sizes above 16
on my end found that it consistently increased WAL overhead, without
providing any meaningful performance improvements.
==Performance==
Local runs on an 8-core M2 Mac with 2 GB shared buffers reconstructed
the 5M-point workloads described in your email. The original SQL was not
included, so this was not an exact reproduction, but the direction of
the performance gains was consistent with your results.
Sorted-tree joins were about 1.6-1.9x faster, and the 500k-row INSERT
was about 1.4x faster. That INSERT generated approximately 5% more
whole-statement WAL under the tested settings.
==Correctness==
I believe I have found two implementation issues:
1. The group penalty is not a guaranteed lower bound.
In gistchoose(), the implementation treats the group summary's insertion
penalty as a lower bound on its members' penalties. A member can have a
lower penalty than both the group summary and the best candidate already
found, so the pruning can skip a better insertion target.
For point_ops, the penalty measures bounding-box area growth. If the
group box is taller than a member box, expanding both horizontally by
the same distance adds more area to the group box. The same applies to a
wider group box expanded vertically.
I was able to reproduce a better candidate being skipped with
ordinary SQL inserts. Is there a way to get a safe lower bound for the group?
2. The TAP result comparison can use the same index on both sides.
In exact_result() it permits but does not force a sequential scan.
For the initial 40,000-row fixture, both settings selected the same GiST
Index Scan.
Because of that, the comparison could pass even if that index scan returned
incorrect results.
Conclusion
----------
Overall, this direction for internal-page indexing looks promising to
me. Storing derived skiptuples in ordinary tuple space with
InvalidBlockNumber as the marker looks reasonable, and the measured
tradeoffs support pursuing the design further.
Paul, I'd appreciate your thoughts on the representation, particularly
how it relates to your ideas for GiST ordering and whether you see
architectural concerns this review has not addressed.
Best Regards,
Ethan
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Antonin Houska | 2026-12-01 17:09:07 | Re: Allow progress tracking of sub-commands |
| Previous Message | Greg Burd | 2026-12-01 16:41:09 | Re: Interrupts vs signals |