Re: smart copy?

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Joel Burton <joel(at)joelburton(dot)com>, Lucas Rockwell <lr(at)socrates(dot)Berkeley(dot)EDU>, pgsql-admin(at)postgresql(dot)org
Subject: Re: smart copy?
Date: 2002-04-26 23:33:57
Message-ID: 200204262333.g3QNXvu28948@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Tom Lane wrote:
> "Joel Burton" <joel(at)joelburton(dot)com> writes:
> > $ pg_dump --attribute-inserts --data-only --table=TheTable A
> >
> > It's slower than running COPY, since you're executing
> > dozens/hundreds/kajillions of INSERT commands rather than one COPY command.
>
> Yup, lots slower. A better idea (which also doesn't require redoing
> the export) is:
>
> 1. Create a temp table that matches the columns present in your data
> file.
>
> 2. COPY from data file into temp table.
>
> 3. INSERT INTO target_table (column list) SELECT * FROM temp_table;
>
> You can do pretty much any transformation you need to in the
> INSERT/SELECT, so this generalizes to a lot of related cases
> where your data file doesn't quite match the data layout you want.

It would be easier if we supported COPY out of views. You could create
the view you want and COPY out that. Unfortunately, we don't support
COPY of views.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Gaetano Mendola 2002-04-27 09:55:55 strange behaviour
Previous Message Tom Lane 2002-04-26 22:50:42 Re: smart copy?