postgresql - Difference between INSERT and COPY -
as per documentation,
loading large number of rows using copy faster using insert, if prepare used , multiple insertions batched single transaction.
why copy faster insert (multiple insertion batched single transaction) ?
quite number of reasons, actually, main ones are:
typically, client applications wait confirmation of 1
insert's success before sending next. there's round-trip delay eachinsert, scheduling delays, etc. (pgjdbc supports pipelineinginserts in batches, i'm not aware of other clients do).each
inserthas go through whole executor. use of prepared statement bypasses need run parser, rewriter , planner, there's still executor state set , tear down each row.copysetup once, , has extremely low overhead each row, no triggers involved.
the first point significant. it's network round-trips , rescheduling delays.
Comments
Post a Comment