pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: Query plan for "id IS NULL" on PK
Date: Tue, 14 Feb 2023 23:43:04 +0100
Message-ID: <20230214224304.ykdgobmkqpaygbth@hjp.at> (raw)
In-Reply-To: <8e744026-7547-5d4d-b76c-ca152881ccce@gmail.com>
References: <CALRaRxzGqDbry9r+0KY5WhpY1xB=o3v3ywrQy2BRUYqZeY5fdQ@mail.gmail.com>
	<8e622f19-bc95-eac3-188d-b03734f547f6@gmail.com>
	<CAKFQuwb3mMRL-bAsMSo3ks78_4cYCV5qptxHPs7mSoKPz1w5Pg@mail.gmail.com>
	<8e744026-7547-5d4d-b76c-ca152881ccce@gmail.com>

On 2023-02-14 15:36:32 -0700, Rob Sargent wrote:
> But if the query is supposed to be generic and re-used in a situation where id
> could be null, wouldn't the null id records be fetched every time? 

No, they will never be fetched because of the AND (("id" <= ?)).

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (11+ messages)  latest in thread

Message-ID: <20230214224304.ykdgobmkqpaygbth@hjp.at>
Permalink:  ../20230214224304.ykdgobmkqpaygbth@hjp.at/
Also on:    postgresql.org/message-id/20230214224304.ykdgobmkqpaygbth@hjp.at

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: hjp-pgsql@hjp.at
  Subject: Re: Query plan for "id IS NULL" on PK
  In-Reply-To: <20230214224304.ykdgobmkqpaygbth@hjp.at>
  References: <CALRaRxzGqDbry9r+0KY5WhpY1xB=o3v3ywrQy2BRUYqZeY5fdQ@mail.gmail.com> <8e622f19-bc95-eac3-188d-b03734f547f6@gmail.com> <CAKFQuwb3mMRL-bAsMSo3ks78_4cYCV5qptxHPs7mSoKPz1w5Pg@mail.gmail.com> <8e744026-7547-5d4d-b76c-ca152881ccce@gmail.com> <20230214224304.ykdgobmkqpaygbth@hjp.at>

* 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