DEV Community

Discussion on: Speed up your PostgreSQL bulk inserts with COPY

Collapse
 
stephenflavin profile image
Stephen Flavin • Edited

I recently did some testing on this with jdbc and managed 3M rows per second on an M1 mac with copy in a single thread however you lose the ability to use on conflict ....
It's possible to improve the performance of inserts I found by replacing values (..., ...), (..., ...) with select unnest(?), unnest(?) with each ? representing an array of values for column1, column2, this method was 3x faster than values in my tests at 850k rows per second.
(Lib used for copy with jdbc github.com/PgBulkInsert/PgBulkInsert)