Re: SLOPE - Planner optimizations on monotonic expressions.

From: Alexandre Felipe <o(dot)alexandre(dot)felipe(at)gmail(dot)com>
To: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: SLOPE - Planner optimizations on monotonic expressions.
Date: 2026-06-01 13:07:47
Message-ID: CAE8JnxMxePAVgi2BuM=_u1_G=6Bt9YoOWuPS=MTW2j9VWGV2Gg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

This patch set adds 0007 "FIX NaN special cases"
filter the index pathkeys that could produce NaN values out of order

By special values I mean the non-real numeric values +Infinity, -Infinity,
NaN.

Cases considered.
(1) Input type supports special values, and functions are decreasing.
(2) Adding or subtracting infinity to a variable of a type that supports
special values.
(3) Multiplication by infinity, as the 0 * Infinity is out of order.
(4) Dividing by infinity a variable that supports special values.

The case (1) is treated when building the pathkey to handle properly cases
like (1 - (1 - x)) where the expression is increased but depends on some
decreasing sub expression.

Regards,
Alexandre

On Sun, May 10, 2026 at 4:53 PM Alexandre Felipe <
o(dot)alexandre(dot)felipe(at)gmail(dot)com> wrote:

>
> On Fri, May 8, 2026 at 11:19 PM Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
> wrote:
>
>> I found one more corner case with infinities (same applies also with
>> negative infinity):
>>
>
> This will restrict a lot of cases.
>
>
> slope_corner_cases.sql enumerate experssions and orders producing
> permutations of (-inf, -1, 0, 1, +inf, nan) mapped to (1,2,3,4,5,6)
> to visualize other similar corner cases.
>
> Apparently the violations boil down to two cases
> * All basic arithmetic operations with infinity constant (with a lucky
> exception x - inf)
> * Every decreasing function where the index key.
> e.g. `-x desc` would have NaNs first
>
> Should I simply detect and disable the above cases?
>
> sqrt(x < 0) already raise an exception, is it safe to assume that for all
> the limited domain functions?
>
>
>
>

Attachment Content-Type Size
v8-0003-SLOPE-prosupport-definitions.patch application/octet-stream 10.3 KB
v8-0004-SLOPE-catalog-changes.patch application/octet-stream 84.9 KB
v8-0001-benchmark.patch application/octet-stream 4.8 KB
v8-0005-SLOPE-Planner-support.patch application/octet-stream 39.2 KB
v8-0002-Optimized-reverse-pathkeys.patch application/octet-stream 6.2 KB
v8-0006-SLOPE-redundancy-checks.patch application/octet-stream 14.0 KB
v8-0007-FIX-NaN-special-cases.patch application/octet-stream 31.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Atsushi Torikoshi 2026-06-01 13:10:41 Re: RFC: Allow EXPLAIN to Output Page Fault Information
Previous Message Shinya Kato 2026-06-01 12:33:33 Add autovacuum_warning to surface concurrent vacuum collisions