Re: Why is a sort required for this query? (IS NULL predicate on leading key column)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jerry Brenner <jbrenner(at)guidewire(dot)com>
Cc: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: Why is a sort required for this query? (IS NULL predicate on leading key column)
Date: 2024-01-17 15:11:17
Message-ID: 2027067.1705504277@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Jerry Brenner <jbrenner(at)guidewire(dot)com> writes:
> I'm wondering why a sort is required for this query, as the index should be
> providing the required ordering to satisfy the ORDER BY clause. Does it
> have to do with the IS NULL predicate on the leading key column in the
> index?

IS NULL is not seen as an equality condition, no. It's pretty much
of a hack that makes it an indexable condition at all, and we don't
really do any advanced optimization with it.

regards, tom lane

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Jean-Christophe Boggio 2024-01-19 06:48:52 I don't understand that EXPLAIN PLAN timings
Previous Message Jerry Brenner 2024-01-17 14:48:54 Re: Why is a sort required for this query? (IS NULL predicate on leading key column)