Re: Index ordering after IS NULL - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Index ordering after IS NULL
Date
Msg-id 667833.1662862713@sss.pgh.pa.us
Whole thread Raw
In response to Index ordering after IS NULL  (Jeff Janes <jeff.janes@gmail.com>)
List pgsql-hackers
Jeff Janes <jeff.janes@gmail.com> writes:
> On a two-column btree index, we can constrain the first column with
> equality and read the rows in order by the 2nd column.  But we can't
> constrain the first column by IS NULL and still read the rows in order by
> the 2nd column.  But why not?

"x IS NULL" doesn't give rise to an EquivalenceClass, which is what
is needed to drive the deduction that the first index column isn't
affecting the result ordering.

Maybe we could extend the notion of ECs to allow that, but I'm not
too sure about how it'd work.  There are already some expectations
that EC equality operators be strict, and this'd blow a large hole
in a lot of related assumptions.  For example, given "x IS NULL AND
x = y", the correct deduction is not "y IS NULL", it's that the
WHERE condition is constant-FALSE.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Splitting up guc.c
Next
From: Justin Pryzby
Date:
Subject: Re: Bump MIN_WINNT to 0x0600 (Vista) as minimal runtime in 16~