Re: GiST multirange index scans can fail to return rows

From: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
To: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
Cc: Peter Geoghegan <pg(at)bowt(dot)ie>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: GiST multirange index scans can fail to return rows
Date: 2026-08-02 15:30:04
Message-ID: CAPpHfduoQZLnShFhLhY4g=_gOLGeC8YDNCc9rwy57e__-BxNtw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Peter,
Hi Andrey,

On Sun, Aug 2, 2026 at 9:55 AM Andrey Borodin <x4mmm(at)yandex-team(dot)ru> wrote:
>
> > On 2 Aug 2026, at 12:03, Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
> >
> > I think that you forgot to attach the patch with the actual fix?
>
> Oops. Sorry.

Peter, thank you for catching this. Andrey, thank you for the patch.
Yes, multirange_gist_consistent() re-uses consistent functions from
range opclass. And range_gist_consistent_leaf_multirange() generate
false negatives when applied to union range of multirange. I've
rechecked, and it appears to be the only case among the predicates.

Regarding this contained-by case, I think we can build more precise
test function. If we have multiranges q and k, and union() produces
union range from multirange.

q @> r doesn't mean q @> union(r)
But if q @> r then union(q) @> union(r)

------
Regards,
Alexander Korotkov
Supabase

Attachment Content-Type Size
v3-0001-Fix-GiST-contained-by-scans-of-multiranges.patch application/octet-stream 6.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Lakhin 2026-08-02 16:00:00 Re: walsummarizer can get stuck when switching timelines
Previous Message jian he 2026-08-02 11:52:40 Re: bug, ALTER TABLE call ATPostAlterTypeCleanup twice for the same relation