Re: bulk insert performance problem

Mark Stosberg <mark@summersault.com>

From: Mark Stosberg <mark@summersault.com>
To: pgsql-performance@postgresql.org
Date: 2008-04-08T13:50:40Z
Lists: pgsql-performance
Christian Bourque wrote:
> 
> Any idea? Is there any other improvements I could do?

Are you using the "COPY" syntax in the import script or individual 
insert statements? Using COPY will always be *much* faster.

I believe COPY always appends to tables rather than replacing the 
contents, you can combine this technique with the possibility of 
splitting up the task into multiple copy statements, but that has never 
been necessary in my case, switching from INSERTS to a COPY statement 
always provided the huge performance improvement I needed.

It's easy to confuse "pg_dump -d" with "psql -d" ...it's too bad they 
mean very different things.

For pg_dump, "-d" causes INSERT statements to be generated instead of a 
COPY statement, and is has been a mistake I made in the past, because I 
expected to work like "psql -d", where "-d" means "database name".

I suppose the safe thing to do is to avoid using "-d" altogether!


	Mark