Re: COPY speedup

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Reg Me Please <regmeplease(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: COPY speedup
Date: 2007-12-13 18:56:02
Message-ID: 17976.1197572162@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Reg Me Please <regmeplease(at)gmail(dot)com> writes:
> In order to speed up the COPY ... FROM ... command, I've
> disabled everything (primary key, not null, references, default and indexes)
> in the table definition before doing the actual COPY.
> Later I can restore them with ALTER TABLE ... and CREATE INDEX ...

> My question is: is all this necessary, or could I save some of them (maybe
> just the DEFAULT) with no speed cost?

Indexes and foreign key references are the only things that benefit
from this treatment. DEFAULTs are irrelevant to a COPY, and simple
constraints (NOT NULL and CHECK) are not any faster to verify later
--- which makes dropping them slower, since you'll need an additional
table scan to verify them when they're re-added.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Uwe C. Schroeder 2007-12-13 19:05:35 Re: For the SQL gurus out there
Previous Message peter pilsl 2007-12-13 18:42:00 extend "group by" to include "empty relations" ?