Re: copy vs. insert w/ no autocommit

From: Francisco Reyes <lists(at)natserv(dot)com>
To: Matthew Kennedy <mkennedy(at)opushealthcare(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: copy vs. insert w/ no autocommit
Date: 2001-12-20 00:37:54
Message-ID: 20011219193418.R5735-100000@zoraida.natserv.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message t.ngockhoi 2001-12-20 08:38:15 Operation eq with varchar
Previous Message Matt Sauve-Frankel 2001-12-20 00:28:00 Re: More on Too Many Open Files... NetBSD