SLOPE - Planner optimizations on monotonic expressions.

From: Alexandre Felipe <o(dot)alexandre(dot)felipe(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: SLOPE - Planner optimizations on monotonic expressions.
Date: 2026-02-11 21:02:53
Message-ID: CAE8JnxN8kLUMygXb33LC-UPGyTC0cTcCyeWUdfEoz=OBo3aT5g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Motivation:
Consider a table data with an indexed timestamp column ts,
the query `SELECT ts::date, count(1) GROUP BY 1;` requires
ts::date to be sorted, but the planner is not aware of the fact
that ts::date will ordered whenever ts is ordered.

This includes slope information to several builtin functions.
type casting, addition, subtraction, common mathematical functions,
e.g. atan, sinh, log, exp, erf, etc. And some date manipulation function.
This may not be complete, but already covers obvious cases.

e.g. SELECT created_at::date, count(1) FROM tasks GROUP BY 1;

can use an index on created_at, to count tasks per day.

You can find examples of howthis feature can be useful in the test file,
including
- Ordered outputs without a sorting node.
- GroupAggregate used directly on the index scan
- MinMaxAggregate replaced by Index scan + limit.

Attachment Content-Type Size
0002-SLOPE-Builtin-support.patch application/octet-stream 52.7 KB
0003-SLOPE-Tests.patch application/octet-stream 21.8 KB
0001-SLOPE-Analysis-Machinery.patch application/octet-stream 13.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2026-02-11 21:05:03 Re: Regression failures after changing PostgreSQL blocksize
Previous Message Nathan Bossart 2026-02-11 21:00:51 Re: pg_upgrade: transfer pg_largeobject_metadata's files when possible