Re: Copy Questions - Mailing list pgsql-novice

From Tom Lane
Subject Re: Copy Questions
Date
Msg-id 28042.1043456378@sss.pgh.pa.us
Whole thread Raw
In response to Copy Questions  ("Chad Thompson" <chad@weblinkservices.com>)
List pgsql-novice
"Chad Thompson" <chad@weblinkservices.com> writes:
> I have csv files that are sent to me on a regular basis.  ~ 50k records a p=
> iece.
> I have been simply using insert to date, but wonder if copy would give me b=
> etter performance.

Certainly.

> My questions are:
> 1) If I use copy, the docs suggest that I copy to a temp table then insert =
> into mytable from temptable, in order for the sequence to fire.
> Does the copy of 7.3 allow sequences to fire during copy?

Yes, in 7.3 you can specify that the data coming from the file fills
only selected columns of the table; the other columns are then filled
with defaults (such as sequence values).

The temp-table idea is mainly useful if you want to massage the data
before you actually insert it --- for instance, do arithmetic, trim
trailing blanks, or whatever.  You can do all that stuff in the
INSERT/SELECT command.

> 2) The docs also suggest that I drop my indexes and reindex.

This would only make sense when the new data represents a large fraction
of the total table size.

            regards, tom lane

pgsql-novice by date:

Previous
From: "Devinder K Rajput"
Date:
Subject: Re: Can't read input file
Next
From: Desmond Coughlan
Date:
Subject: Altering Column Date Types