Re: COPY vs INSERT - Mailing list pgsql-performance

From Tom Lane
Subject Re: COPY vs INSERT
Date
Msg-id 16747.1115259776@sss.pgh.pa.us
Whole thread Raw
In response to Re: COPY vs INSERT  (Christopher Kings-Lynne <chriskl@familyhealth.com.au>)
Responses Re: COPY vs INSERT  ("Jim C. Nasby" <decibel@decibel.org>)
List pgsql-performance
Christopher Kings-Lynne <chriskl@familyhealth.com.au> writes:
>> So what's the difference between a COPY and a batch of INSERT
>> statements.  Also, surely, fsyncs only occur at the end of a
>> transaction, no need to fsync before a commit has been issued, right?

> With COPY, the data being inserted itself does not have to pass through
> the postgresql parser.

Also, there is a whole lot of one-time-per-statement overhead that can
be amortized across many rows instead of only one.  Stuff like opening
the target table, looking up the per-column I/O conversion functions,
identifying trigger functions if any, yadda yadda.  It's not *that*
expensive, but compared to an operation as small as inserting a single
row, it's significant.

            regards, tom lane

pgsql-performance by date:

Previous
From: Christopher Kings-Lynne
Date:
Subject: Re: COPY vs INSERT
Next
From: Mischa Sandberg
Date:
Subject: Re: COPY vs INSERT