From: | Charles Pritchard <chuck(at)jumis(dot)com> |
---|---|
To: | Alessandro Gherardi <alessandro(dot)gherardi(at)yahoo(dot)com> |
Cc: | pgsql-jdbc(at)lists(dot)postgresql(dot)org |
Subject: | Re: IN or ANY for batch queries |
Date: | 2018-05-27 00:49:06 |
Message-ID: | CANpQ4dzxZbm9=2LR1B2Qp0E4oZcaQY+X9u_k+y2m2-jr-qmfvw@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Go ahead an test the array length; if it's large, create a temporary table
and run a batch insert.
That's been my experience in -everything- whether SQLite, PostgreSQL or
HiveQL.
On Fri, May 25, 2018, 7:10 PM Alessandro Gherardi <
alessandro(dot)gherardi(at)yahoo(dot)com> wrote:
> 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
>
From | Date | Subject | |
---|---|---|---|
Next Message | Craig Ringer | 2018-05-28 01:37:10 | Re: IN or ANY for batch queries |
Previous Message | Dave Cramer | 2018-05-27 00:34:58 | Re: IN or ANY for batch queries |