Re: SLOPE - Planner optimizations on monotonic expressions.

Alexandre Felipe <o.alexandre.felipe@gmail.com>

From: Alexandre Felipe <o.alexandre.felipe@gmail.com>
To: Zsolt Parragi <zsolt.parragi@percona.com>
Cc: Dean Rasheed <dean.a.rasheed@gmail.com>, Corey Huinker <corey.huinker@gmail.com>, pgsql-hackers@postgresql.org
Date: 2026-05-10T15:53:49Z
Lists: pgsql-hackers

Attachments

On Fri, May 8, 2026 at 11:19 PM Zsolt Parragi <zsolt.parragi@percona.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?