From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Alban Hertroys <haramrae(at)gmail(dot)com> |
Cc: | Dominique Devienne <ddevienne(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: WHERE col = ANY($1) extended to 2 or more columns? |
Date: | 2023-02-09 16:37:29 |
Message-ID: | CAKFQuwa20KW+Lza0NrOXTQxcpFJRQG=zjwz4LkB9u7DXxEHkBg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, Feb 9, 2023 at 9:28 AM Alban Hertroys <haramrae(at)gmail(dot)com> wrote:
>
> > On 9 Feb 2023, at 16:41, Dominique Devienne <ddevienne(at)gmail(dot)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)
>
>
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.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2023-02-09 16:51:13 | Re: Using PostgreSQL for service discovery and health-check |
Previous Message | Alban Hertroys | 2023-02-09 16:28:37 | Re: WHERE col = ANY($1) extended to 2 or more columns? |