Re: SLOPE - Planner optimizations on monotonic expressions.
Dean Rasheed <dean.a.rasheed@gmail.com>
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: Alexandre Felipe <o.alexandre.felipe@gmail.com>
Cc: Zsolt Parragi <zsolt.parragi@percona.com>,
Corey Huinker <corey.huinker@gmail.com>, pgsql-hackers@postgresql.org
Date: 2026-03-26T18:17:11Z
Lists: pgsql-hackers
On Wed, 25 Mar 2026 at 23:35, Alexandre Felipe <o.alexandre.felipe@gmail.com> wrote: > > Good catch, > Can you think of any other type that would wrap, Arithmetic with intervals isn't monotonic in general because of the way interval time units vary. For example, '1 month - 29 days' is "positive" (in the sense that it compares as greater than zero, and it compares equal to an interval of '1 day'), but adding it to a date or timestamp may go forwards or backwards, or not move at all, depending on the number of days in the month. Another example, is the interval '361 days', which compares as greater than the interval '1 year' (because that's taken to be 12 months of 30 days each). But adding '361 days' to a date or timestamp advances it by less than a year. So ordering by an interval column can produce different results than ordering by a fixed date/timestamp plus the interval. Regards, Dean