Message-ID: From: "vlsi (@vlsi)" To: "pgjdbc/pgjdbc" Date: Sat, 20 Sep 2025 06:25:07 +0000 Subject: Re: [pgjdbc/pgjdbc] issue #3811: PreparedStatement batch performance issue in a loop on v42.7.6 or later In-Reply-To: References: List-Id: X-GitHub-Author-Login: vlsi X-GitHub-Comment-Id: 3314629567 X-GitHub-Comment-Type: issue_comment X-GitHub-Issue: 3811 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-Type: comment X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/3811#issuecomment-3314629567 Content-Type: text/plain; charset=utf-8 @leandrokemp , Previously, `ps.toString();` rendered only the the last value, and 0a88ea425e86dce691a96d6aa7023c20ac887b98 probably fixed it, so now `ps.toString()` renders all the values in a batch. Now `ps.toString()` properly displays all the values it is about to send to the database, and it is far `toString()` to take longer time as the list of values grows. This makes `ps.toString(); ps.addBatch()` loop behave with O(N^2) properties, thus it effectively hangs. If you want to log the executed statement, you'd better move the logging out of the loop just before `executeBatch`. I am leaning towards to closing the issue with "working as expected, won't fix" resolution unless you justify the business case behind calling `ps.toString(); ps.addBatch();` within a loop.