Re: IN or ANY for batch queries

From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Charles Pritchard <chuck(at)jumis(dot)com>
Cc: Alessandro Gherardi <alessandro(dot)gherardi(at)yahoo(dot)com>, pgsql-jdbc(at)lists(dot)postgresql(dot)org
Subject: Re: IN or ANY for batch queries
Date: 2018-05-28 01:37:10
Message-ID: CAMsr+YGHv96JK875v4n83rV_uPwi4J6VndfMPpjFeMJc5TKuZQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

PostgreSQL translates IN (...) to = ANY(ARRAY[...]) internally. They're
largely the same thing.

In theory for small IN lists it could specialize the query into a union
with specialized plans for different values, but it doesn't do that.

Charles is right. For smaller sets use either form, whatever is convenient.
For larger sets create a temp table, COPY to populate it, create indexes on
it if you need to, and join on it.

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Vladimir Sitnikov 2018-05-28 10:34:19 Re: IN or ANY for batch queries
Previous Message Charles Pritchard 2018-05-27 00:49:06 Re: IN or ANY for batch queries