Re: COPY versus INSERT - Mailing list pgsql-general

From Richard Huxton
Subject Re: COPY versus INSERT
Date
Msg-id 200305141655.13890.dev@archonet.com
Whole thread Raw
In response to COPY versus INSERT  ("Jay O'Connor" <joconnor@cybermesa.com>)
Responses Re: COPY versus INSERT  ("alex b." <mailinglists1@gmx.de>)
List 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

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: server process segfaulting
Next
From: Fernando Flores Prior
Date:
Subject: Re: - what protocol for an Internet postgres