Batch INSERTs/UPDATEs #2701
-
Using the addBatch method on a PreparedStatement and then eventually calling executeBatch() every 1000 rows. My expectation was that this would generate a single INSERT with multiple VALUEs (i.e. INSERT INTO mytable (cola) VALUES (1), (2), (3), (4)...). However, it appears to be only queuing up individual INSERT statements and then executing them all at once when executeBatch is called. Is my observation correct? If so, is there a way to get the multiple VALUE result instead of individual INSERTs (row by row processing)? My current expectation is that I would need to manually (so to speak) assemble the INSERT and call execute() to get the expected behaviour. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The server does not support this, but we do have a way to rewrite the query You can use the |
Beta Was this translation helpful? Give feedback.
The server does not support this, but we do have a way to rewrite the query
You can use the
reWriteBatchedInserts
property to enable this behaviour see https://jdbc.postgresql.org/documentation/use/