Re: JDBC prepared statement: a 32767 limit of arguments number

From: Vladislav Malyshkin <mal(at)gromco(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "pgsql-jdbc(at)lists(dot)postgresql(dot)org" <pgsql-jdbc(at)lists(dot)postgresql(dot)org>
Subject: Re: JDBC prepared statement: a 32767 limit of arguments number
Date: 2022-03-09 19:38:05
Message-ID: bb23919c-fc6d-d4db-541d-d051b1db491a@gromco.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">
<div class="moz-cite-prefix">On 09/03/2022 10.03, Tom Lane wrote:<br>
</div>
<blockquote type="cite" cite="mid:515148(dot)1646838226(at)sss(dot)pgh(dot)pa(dot)us"><br>
<pre class="moz-quote-pre" wrap="">I concur with David's opinion that if you think you need more
parameters, you're doing it wrong. One idea to consider is
aggregating similar values into an array parameter.</pre>
</blockquote>
<br>
I disagree:<br>
<br>
1. It is extremely convenient to insert multiple values in a
single SQL insert:<br>
<p><b>INSERT INTO table_name (f1,f2,f3) VALUES (1,"text",2.4),
(2,"text2",2.5),...</b></p>
Setting all values as JDBC parameters is the easiest way to
integrate java/scala and SQL. <br>
A single insert of 10000 records is several orders of magnitudes <b>faster</b>
than 10000 separate inserts, not to mention transaction
simplification.<br>
<br>
2. For automatic scala&lt;-&gt;jdbc integration tools such as <a
class="moz-txt-link-freetext"
href="https://github.com/mal19992/sqlps">https://github.com/mal19992/sqlps</a>
a number of  JDBC arguments can be generated by an automatic
transformation, the SQL and JDBC arguments are autogenerated and
can be a very large number. <br>
Suggested by David approach "like using a temp table and a join
instead of an IN operator." is extremely inconvenient for
automatic tools.<br>
<br>
Vladislav<br>
</div>
</body>
</html>

Attachment Content-Type Size
unknown_filename text/html 1.6 KB

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message David G. Johnston 2022-03-09 19:55:18 Re: JDBC prepared statement: a 32767 limit of arguments number
Previous Message Tom Lane 2022-03-09 15:03:46 Re: JDBC prepared statement: a 32767 limit of arguments number