pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jerry Brenner <jbrenner@guidewire.com>
Cc: pgsql-performance@lists.postgresql.org
Subject: Re: Why is a sort required for this query? (IS NULL predicate on leading key column)
Date: Wed, 17 Jan 2024 10:11:17 -0500
Message-ID: <2027067.1705504277@sss.pgh.pa.us> (raw)
In-Reply-To: <CACoKFYRfJjpaG+yXAZXdTm7b7UAk4UQwV3-b2H_nmYUMS1TBgA@mail.gmail.com>
References: <CACoKFYRfJjpaG+yXAZXdTm7b7UAk4UQwV3-b2H_nmYUMS1TBgA@mail.gmail.com>

Jerry Brenner <jbrenner@guidewire.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





view thread (3+ messages)

Message-ID: <2027067.1705504277@sss.pgh.pa.us>
Permalink:  ../2027067.1705504277@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2027067.1705504277@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jbrenner@guidewire.com, pgsql-performance@lists.postgresql.org
  Subject: Re: Why is a sort required for this query? (IS NULL predicate on leading key column)
  In-Reply-To: <2027067.1705504277@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox