pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alban Hertroys <haramrae@gmail.com>
To: Dominique Devienne <ddevienne@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: WHERE col = ANY($1) extended to 2 or more columns?
Date: Thu, 9 Feb 2023 17:28:37 +0100
Message-ID: <024441B3-5505-42FB-A665-8DE93B54A1C7@gmail.com> (raw)
In-Reply-To: <CAFCRh-_7VMpCBFk6iGMN12gJF2hfX-iWU1QReVrjsgyJt0wKiQ@mail.gmail.com>
References: <CAFCRh-_7VMpCBFk6iGMN12gJF2hfX-iWU1QReVrjsgyJt0wKiQ@mail.gmail.com>


> On 9 Feb 2023, at 16:41, Dominique Devienne <ddevienne@gmail.com> wrote:
> 
> Hi. We are implementing an API which takes a list of row keys, and must return info about those rows. To implement that efficiently, in as few round-trips as possible, we bind a (binary) array of keys (ints, uuids, or strings) and that works great, but only if the key is a scalar one.
> 
> Now we'd like to do the same for composite keys, and I don't know how to do that.
> Is it possible? Could someone please help out or demo such a thing?
> We are doing it in C++ using libpq, but a pure SQL or PL/pgSQL demo would still help (I think).

This works:

=> select (1, 'one'::text) in ((1, 'two'::text), (2, 'one'::text), (1, 'one'::text), (2, 'two'::text));
 ?column? 
----------
 t
(1 row)

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.






view thread (11+ messages)  latest in thread

Message-ID: <024441B3-5505-42FB-A665-8DE93B54A1C7@gmail.com>
Permalink:  ../024441B3-5505-42FB-A665-8DE93B54A1C7@gmail.com/
Also on:    postgresql.org/message-id/024441B3-5505-42FB-A665-8DE93B54A1C7@gmail.com

 · 

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: haramrae@gmail.com, ddevienne@gmail.com
  Subject: Re: WHERE col = ANY($1) extended to 2 or more columns?
  In-Reply-To: <024441B3-5505-42FB-A665-8DE93B54A1C7@gmail.com>
  References: <CAFCRh-_7VMpCBFk6iGMN12gJF2hfX-iWU1QReVrjsgyJt0wKiQ@mail.gmail.com> <024441B3-5505-42FB-A665-8DE93B54A1C7@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