Re: copy vs. insert w/ no autocommit - Mailing list pgsql-general

From Francisco Reyes
Subject Re: copy vs. insert w/ no autocommit
Date
Msg-id 20011219193418.R5735-100000@zoraida.natserv.net
Whole thread Raw
In response to copy vs. insert w/ no autocommit  (Matthew Kennedy <mkennedy@opushealthcare.com>)
List pgsql-general
On 18 Dec 2001, Matthew Kennedy wrote:

> I realize a COPY statement is much faster than individual INSERT
> statements.

How? Have you tested it? Or do you mean that from reading people's
comments you believe this to be "common knowledge".

>But how does COPY compare to individual INSERTS within a
>BEGIN/END or with setAutoCommit(false)?

Are we talking "copy" or "\copy"?

I am not sure about \copy, but "copy" as far as I know doesn't update all
the stats/indexes so it should be significantly faster to use a copy.

So far for all my big jobs (anything greater than a few thousand rows) I
always use copy and it is fairly fast.

Have you tried doing some testing? How many indexes do you have on the
table?

> If there's a difference, are we
> talking orders-of-magnitude in difference?

Depending on your disk subsistem I would expect copy should be several
times faster due to index overhead.


pgsql-general by date:

Previous
From: marc@oscar.eng.cv.net (Marc Spitzer)
Date:
Subject: Re: Migrate Store Procedure Sybase to PostgreSQL
Next
From: Matt Sauve-Frankel
Date:
Subject: Re: More on Too Many Open Files... NetBSD