Václav
Václav

Reputation: 460

How to produce a postgresql dump of multi-valued INSERTs instead of COPY and to batch the inserts into explicit transactions?

I cannot find anywhere any info on how exactly should I bulk my inserts into batches of 100-inserts-per-transaction while producing a database dump via pg_dump utility. How exactly do I need to perform it? I failed to find any parameters in

> man pg_dump

to perform this. Even the most elaborate answer on StackOverflow on the topic by @CraigRinger does not describe the way the dump of extended imports may be produced. Could anyone please share their recipe here?

Upvotes: 4

Views: 2209

Answers (1)

jjanes
jjanes

Reputation: 44167

--rows-per-insert was added to pg_dump for v12. Before that, there is no clean way to do this.

With plain text dumps, the transaction control will be decided based on how you replay the dump, not on how you take it. If you just stream the dump into psql with no options, each insert will naturally be its own transaction.

Upvotes: 7

Related Questions