Re: WHERE col = ANY($1) extended to 2 or more columns? - Mailing list pgsql-general

From Dominique Devienne
Subject Re: WHERE col = ANY($1) extended to 2 or more columns?
Date
Msg-id CAFCRh-9ALd0kvGKxuj6oMMzxr2jcO=7nrcgx0V9vaGMZ0tbBhA@mail.gmail.com
Whole thread Raw
In response to Re: WHERE col = ANY($1) extended to 2 or more columns?  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: WHERE col = ANY($1) extended to 2 or more columns?  (Alban Hertroys <haramrae@gmail.com>)
Re: WHERE col = ANY($1) extended to 2 or more columns?  ("Peter J. Holzer" <hjp-pgsql@hjp.at>)
List pgsql-general
On Thu, Feb 9, 2023 at 5:37 PM David G. Johnston <david.g.johnston@gmail.com> wrote:
On Thu, Feb 9, 2023 at 9:28 AM Alban Hertroys <haramrae@gmail.com> wrote:
> On 9 Feb 2023, at 16:41, Dominique Devienne <ddevienne@gmail.com> wrote:
> Now we'd like to do the same for composite keys, and I don't know how to do that.

This works:
=> select (1, 'one'::text) in ((1, 'two'::text), (2, 'one'::text), (1, 'one'::text), (2, 'two'::text));
But you cannot write the right-side of the IN as a single parameter which seems to be the primary constraint trying to be conformed to.

Right. The goal is to (re)use a prepared statement (i.e. plan once), and bind the RHS (binary) array
and do a single exec (single round-trip) to get the matching rows. AFAIK, this is the fastest way.
If there's a better/faster way, I'm interested. --DD

pgsql-general by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: ERROR: posting list tuple with 2 items cannot be split at offset 17
Next
From: Dominique Devienne
Date:
Subject: Re: Using PostgreSQL for service discovery and health-check