From: Rob Sargent <robjsargent@gmail.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Query plan for "id IS NULL" on PK
Date: Tue, 14 Feb 2023 15:36:32 -0700
Message-ID: <8e744026-7547-5d4d-b76c-ca152881ccce@gmail.com> (raw)
In-Reply-To: <CAKFQuwb3mMRL-bAsMSo3ks78_4cYCV5qptxHPs7mSoKPz1w5Pg@mail.gmail.com>
References: <CALRaRxzGqDbry9r+0KY5WhpY1xB=o3v3ywrQy2BRUYqZeY5fdQ@mail.gmail.com>
<8e622f19-bc95-eac3-188d-b03734f547f6@gmail.com>
<CAKFQuwb3mMRL-bAsMSo3ks78_4cYCV5qptxHPs7mSoKPz1w5Pg@mail.gmail.com>
On 2/14/23 15:30, David G. Johnston wrote:
> On Tue, Feb 14, 2023 at 3:25 PM Rob Sargent <robjsargent@gmail.com> wrote:
>
>
> When will id be null in a primary key?
>
>
> The OP seems to be aware of this...
>
> "We cannot change the query being executed. Is there any way we can
> make the query planner ignore `OR (id IS NULL)` (as that will never be
> the case for the PK) and use both `id` clauses in the index condition?"
>
> David J.
>
Yes, agreed.
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?
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: robjsargent@gmail.com, david.g.johnston@gmail.com
Subject: Re: Query plan for "id IS NULL" on PK
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>
* 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