Re: COPY versus INSERT

From: Richard Huxton <dev(at)archonet(dot)com>
To: "Jay O'Connor" <joconnor(at)cybermesa(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: COPY versus INSERT
Date: 2003-05-14 15:55:13
Message-ID: 200305141655.13890.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wednesday 14 May 2003 3:23 am, Jay O'Connor wrote:
> I'm loading a database with a lot of data from an external source (I'm
> convertin all my data to postgresql)
>
> Right now I'm just connecting to the database and issuing a whole lot of
> INSERTS and this is taking longer than I had planned.
>
> Would it be faster to just dump my database ina tab delimited format and
> use a COPY FROM or psql /copy command?

Almost always.

Might want to try batching your INSERTs into transactions of a few hundred-few
thousand first though - that frequently helps a lot:

BEGIN;
INSERT ...1
INSERT ...2
...
INSERT ...999
COMMIT;

--
Richard Huxton

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Fernando Flores Prior 2003-05-14 15:56:25 Re: - what protocol for an Internet postgres
Previous Message Tom Lane 2003-05-14 15:53:47 Re: server process segfaulting