От: Tom Lane
Тема: Re: COPY vs INSERT
Дата: ,
Msg-id: 16747.1115259776@sss.pgh.pa.us
(см: обсуждение, исходный текст)
Ответ на: Re: COPY vs INSERT  (Christopher Kings-Lynne)
Ответы: Re: COPY vs INSERT  ("Jim C. Nasby")
Список: pgsql-performance

Скрыть дерево обсуждения

 (Steven Rosenstein, )
 Re:  (Tom Lane, )
  Re: COPY vs INSERT  (Mischa Sandberg, )
   Re: COPY vs INSERT  ("David Roussel", )
    Re: COPY vs INSERT  (Mischa Sandberg, )
     Re: COPY vs INSERT  (Christopher Petrilli, )
      Re: COPY vs INSERT  (Keith Worthington, )
     Re: COPY vs INSERT  (Kris Jurka, )
      Re: COPY vs INSERT  (Mischa Sandberg, )
       Re: COPY vs INSERT  (Kris Jurka, )
    Re: COPY vs INSERT  (John A Meinel, )
    Re: COPY vs INSERT  (Christopher Kings-Lynne, )
     Re: COPY vs INSERT  (Tom Lane, )
      Re: COPY vs INSERT  ("Jim C. Nasby", )
       Re: COPY vs INSERT  (Dennis Bjorklund, )
        Re: COPY vs INSERT  ("Jim C. Nasby", )
       Re: COPY vs INSERT  (Harald Fuchs, )
       Re: COPY vs INSERT  (Bruno Wolff III, )
        Re: COPY vs INSERT  (Tom Lane, )
  Re:  (Mike Rylander, )

Christopher Kings-Lynne <> 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 по дате сообщения:

От: Mischa Sandberg
Дата:
Сообщение: Re: COPY vs INSERT
От: Kris Jurka
Дата:
Сообщение: Re: COPY vs INSERT