Re: SLOPE - Planner optimizations on monotonic expressions.

From: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: SLOPE - Planner optimizations on monotonic expressions.
Date: 2026-07-01 22:00:48
Message-ID: CAN4CZFPhBcNP6jxA4u=V=mie=DNyYe4t8cENCzXk49ojkZ=5JQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Apologies for the late response, somehow I missed this update.

The changes generally look good and seem to work, except one remaining
issue with domains:

CREATE DOMAIN df AS float8;
CREATE TABLE t (id int, x df);
INSERT INTO t VALUES (1,'-inf'),(2,'-1'),(3,'0'),(4,'3'),(5,'inf'),(6,'nan');
CREATE INDEX ON t (x);
SET enable_seqscan=off; SET enable_sort=off; SET enable_bitmapscan=off;
SELECT id, -x AS f FROM t ORDER BY (-x) ASC NULLS FIRST;

/*
* get_const_sign
* Helper to determine the sign of a numeric constant.
* Returns 1 for positive, -1 for negative, 0 for zero or unknown.
*/
-static int
+static inline enum NUMERIC_SIGN

This comment is now outdated. The default value is unreachable
currently, but is 0 still a safe value there?

+enum NUMERIC_SIGN {
+ NUMERIC_SIGN_NINF=-2,
+ NUMERIC_SIGN_NEG=-1,
+ NUMERIC_SIGN_ZERO=0,
+ NUMERIC_SIGN_POS=1,
+ NUMERIC_SIGN_PINF=3,
+ NUMERIC_SIGN_NAN=4,
+ NUMERIC_SIGN_NULL=5,
+};

this is missing a typedef and maybe it should be defined at the
beginning of the file or in a header? Is skipping positive 2
intentional?

The patchset also has many small formatting issues/inconsistencies,
maybe it would be worth to run pgindent on it?

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zsolt Parragi 2026-07-01 22:08:54 Re: proposal - queryid can be used as filter for auto_explain
Previous Message Tom Lane 2026-07-01 21:40:04 Re: POC: PLpgSQL FOREACH IN JSON ARRAY