Re: BUG #19705: One NaN box makes a BRIN box_inclusion_ops index omit unrelated rows

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: kehan5800(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19705: One NaN box makes a BRIN box_inclusion_ops index omit unrelated rows
Date: 2026-09-21 23:49:51
Message-ID: CAGRkXqS=KcB0EKNpC31PnEEuP75mXOxYvYE3M80q78pZK=3TzA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

I can reproduce this on master, and your analysis is right. bound_box()
lets the NaN into the range summary, and then every box operator says
the range cannot match.

You suggested adding a mergeable support function, like inet has. That
works, but it needs a new pg_amproc row, so it cannot go to the back
branches. The same code is in 14 and later.

The attached 0001 fixes bound_box() instead. When an input coordinate is
NaN, the result is infinite on that side. The summary then matches any
query on that axis and the recheck does the rest. Only the NaN axis
becomes lossy, the other axis still prunes.

Existing summaries that hold a NaN stay broken until REINDEX.

0002 adds tests and is optional.

Thanks,
Shihao

Attachment Content-Type Size
v1-0002-Add-tests-for-NaN-handling-in-bound_box-and-BRIN-.patch application/octet-stream 4.5 KB
v1-0001-Fix-BRIN-box_inclusion_ops-losing-rows-when-a-box.patch application/octet-stream 3.1 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2026-09-22 01:26:24 BUG #19711: SSH tunnel with PPK identity file fails/crashes in newer pgAdmin version but works in older version
Previous Message shihao zhong 2026-09-21 23:31:08 Re: BUG #19708: Hash Join becomes about 300x slower with higher work_mem