Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fMOeq-0005H2-HH for pgsql-jdbc@arkaria.postgresql.org; Sat, 26 May 2018 02:10:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fMOep-0007IO-12 for pgsql-jdbc@arkaria.postgresql.org; Sat, 26 May 2018 02:10:11 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fMOeo-0007IB-C5 for pgsql-jdbc@lists.postgresql.org; Sat, 26 May 2018 02:10:10 +0000 Received: from sonic312-22.consmr.mail.bf2.yahoo.com ([74.6.128.84]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fMOel-0007jH-Rm for pgsql-jdbc@lists.postgresql.org; Sat, 26 May 2018 02:10:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1527300605; bh=hK1PtxG+eOrUDeR/cM6U7xmqLlDecxWFjcWYgu76WZA=; h=Date:From:To:Subject:References:From:Subject; b=FH8uNDj4LMmet1LAY7JElhRFT5yEf5JWgtDbHzHpMID/0+d4wRTOAC/ca2yeO9ISjhf9e0w7RKrXFKsv+icOKOARBV2/5K5kGyRzZL1t8DjgjbWeJCvhGA3psWOpVNzRKFcpdbXb9kZzFOobSaCwZZWpx5DfKuEXtxBcQuNis9wcKC/Z7nyXFcdgDueUwCGMPjZDAWOylWOj2Zp4dcOC/cNdEtkzwgA/L/kIIahpFjm4GdhxMVY3Gv+opJFeRqO70v23iIoaqy9l8qp3meXqYMmvPMMebvlhU6HxkN/vhQezro01cXkmjZt527mLQvUM+BjloGjM00covZDJJLPwIA== X-YMail-OSG: ICyVF2oVM1lsbdTglr_DtHeoMbFlwbWujWjonOZZkyQqAhc_bVn81QlijtEATly 7C4EBZzMtWxOXnVZLSZU.MYZ4EsN68UOsPy_l5m7rrnMFHdxBGFBZacn4f9RRE42G3VNOssBi2en XEXg0ieKaiMEGXN.ab_JQRK4Ak8buGUv.a7cFIPnCJdMKAtvTwQZvjVNjH5Lezo_M9zqWq7b9dVg q55cQBgBuQONrU8MqjMrhRNaQqSgLUrCU.HwFZFmv_Q3GsPcSaX25kADjKwOPfmLFqof9Bj52Cmr mai891Dkki1L1wZ97IdOGvtcgy92ahLPjbpNI.n8ToCpb2.fZPjzEa.9GpkU.k4OhKBrKNZd8O6H haGRnMxT3IbCYfcs1LBIQW65.n4o8XDZVl1tHUgGDt115ilK92CRrkj0tRASflICzxxE7xe6jwc1 HCYzeOsqr.Xojpue79M7PFelGscQE1WRDEq3QpHpb2rWfQJefyXErwWAMHtDQg5xYwymVvnPcBud YoWmikxJHnGg3521IdrXCK20923BX3Dbs0XLgaxptdXpZPQlvb0nIphhVML.GEzqLkjmIJMHIJ4y RftgxzLLKWFRUabr2s7u4ugA4vLsuCrxrVAnJXen80m3KaZ2gzDm_ft5ZClRMDn46KTo04DMY Received: from sonic.gate.mail.ne1.yahoo.com by sonic312.consmr.mail.bf2.yahoo.com with HTTP; Sat, 26 May 2018 02:10:05 +0000 Date: Sat, 26 May 2018 02:10:02 +0000 (UTC) From: Alessandro Gherardi To: pgsql-jdbc@lists.postgresql.org Message-ID: <1326195889.5524206.1527300602365@mail.yahoo.com> Subject: IN or ANY for batch queries MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_5524205_953150479.1527300602364" References: <1326195889.5524206.1527300602365.ref@mail.yahoo.com> X-Mailer: WebService/1.1.11871 YMailNorrin Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36 Content-Length: 1813 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_5524205_953150479.1527300602364 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 ------=_Part_5524205_953150479.1527300602364 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
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
------=_Part_5524205_953150479.1527300602364--