pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Ilya Basin <basinilya@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Query plans not identical for `id in(1,2,3)` and `(id=1 or id=2 or id=3)`
Date: Sun, 10 Mar 2024 12:51:31 +0100
Message-ID: <6da830f74343b343b17f020b82570d2e67de8b65.camel@cybertec.at> (raw)
In-Reply-To: <0cf29b7e-3e9e-4698-81e3-aad5bb37f446@gmail.com>
References: <0cf29b7e-3e9e-4698-81e3-aad5bb37f446@gmail.com>

On Sat, 2024-03-09 at 23:08 +0400, Ilya Basin wrote:
> I have a list of bigint keys and I need to retrieve rows by these keys.
> Normally, I would split this list into pages of size 900 and perform
> several `SELECT ... WHERE key in($1,$2,...)`. However, the proprietary
> ORM we use can only produce this SQL:
> `SELECT ... WHERE (key=$1 or key=$2 or ...)`.
> Surprisingly, PostgreSQL planner treats these two SQLs differently:
> 
> Is it possible to configure PostgreSQL 12.16 to treat the second query as the first?

No, that is currently not possible.

Yours,
Laurenz Albe





view thread (4+ messages)  latest in thread

Message-ID: <6da830f74343b343b17f020b82570d2e67de8b65.camel@cybertec.at>
Permalink:  ../6da830f74343b343b17f020b82570d2e67de8b65.camel@cybertec.at/
Also on:    postgresql.org/message-id/6da830f74343b343b17f020b82570d2e67de8b65.camel@cybertec.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: laurenz.albe@cybertec.at, basinilya@gmail.com
  Subject: Re: Query plans not identical for `id in(1,2,3)` and `(id=1 or id=2 or id=3)`
  In-Reply-To: <6da830f74343b343b17f020b82570d2e67de8b65.camel@cybertec.at>
  References: <0cf29b7e-3e9e-4698-81e3-aad5bb37f446@gmail.com> <6da830f74343b343b17f020b82570d2e67de8b65.camel@cybertec.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