pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <pgman@candle.pha.pa.us>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Joel Burton <joel@joelburton.com>
Cc: Lucas Rockwell <lr@socrates.Berkeley.EDU>
Cc: pgsql-admin@postgresql.org
Subject: Re: smart copy?
Date: Fri, 26 Apr 2002 19:33:57 -0400 (EDT)
Message-ID: <200204262333.g3QNXvu28948@candle.pha.pa.us> (raw)
In-Reply-To: <12691.1019861442@sss.pgh.pa.us>

Tom Lane wrote:
> "Joel Burton" <joel@joelburton.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@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026



view thread (5+ messages)

Message-ID: <200204262333.g3QNXvu28948@candle.pha.pa.us>
Permalink:  ../200204262333.g3QNXvu28948@candle.pha.pa.us/
Also on:    postgresql.org/message-id/200204262333.g3QNXvu28948@candle.pha.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: pgman@candle.pha.pa.us, tgl@sss.pgh.pa.us, joel@joelburton.com, lr@socrates.Berkeley.EDU
  Subject: Re: smart copy?
  In-Reply-To: <200204262333.g3QNXvu28948@candle.pha.pa.us>
  References: <12691.1019861442@sss.pgh.pa.us> <200204262333.g3QNXvu28948@candle.pha.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox