pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alessandro Gherardi <alessandro.gherardi@yahoo.com>
To: pgsql-jdbc@lists.postgresql.org
Subject: IN or ANY for batch queries
Date: Sat, 26 May 2018 02:10:02 +0000 (UTC)
Message-ID: <1326195889.5524206.1527300602365@mail.yahoo.com> (raw)
References: <1326195889.5524206.1527300602365.ref@mail.yahoo.com>

Hi,I'd like to understand if there are any benefits to using SELECT ... WHERE primary_key = ANY(large array of values) as opposed to SELECT ... WHERE primary_key IN(?,?,...) via JDBC.
I'm aware that to use ANY(array), I first have to call array = connection.createArrayOf(Java array), then preparedStatement.setArray(X, array).
I ran a few tests and the latency seems to be pretty much the same. However, since in my application the number of values in the array can vary, I'm wondering if using ANY has the benefit of causing the driver/DB to cache a smaller number of prepared statement.
Any thoughts?
Thank you in advance,Alessandro

view thread (8+ messages)  latest in thread

Message-ID: <1326195889.5524206.1527300602365@mail.yahoo.com>
Permalink:  ../1326195889.5524206.1527300602365@mail.yahoo.com/
Also on:    postgresql.org/message-id/1326195889.5524206.1527300602365@mail.yahoo.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-jdbc@postgresql.org
  Cc: alessandro.gherardi@yahoo.com
  Subject: Re: IN or ANY for batch queries
  In-Reply-To: <1326195889.5524206.1527300602365@mail.yahoo.com>
  References: <1326195889.5524206.1527300602365.ref@mail.yahoo.com> <1326195889.5524206.1527300602365@mail.yahoo.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