pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Conway <mail@joeconway.com>
To: Nigel J. Andrews <nandrews@investsystems.co.uk>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: COPY performance
Date: Sat, 13 Apr 2002 11:38:40 -0700
Message-ID: <3CB87B30.1010203@joeconway.com> (raw)
References: <Pine.LNX.4.21.0204131840360.3278-100000@ponder.fairway2k.co.uk>

Nigel J. Andrews wrote:
> 
> I'm trying to COPY in a table of 1 million rows. The table is created by:
> 
> create table chat_post_new (
>         session_id      INT             NOT NULL references chat_session (session_id),
>         poster_name     VARCHAR(32)     NOT NULL,
>         time            TIMESTAMP       NOT NULL,
>         post_number     INT             NOT NULL,
>         FTS             txtidx
> );
> 
> The old definition had the integer columns as int2s and the FTS column wasn't
> there. Because I wanted to reorder the rows, add them in a more natural order
> (by time), I created the data file read in by the copy command using
> 
> SELECT session_id || '\t' || poster_name || '\t' || time || '\t' || post_number
> 	FROM chat_post
> 	ORDER BY time
> 
> After removing the first and last couple of lines, so that only the data is in
> the file, renaming the original table and creating the new version I tried
> running:
> 
> COPY chat_post FROM 'file-path'
> 

I'm not sure if this is your problem, but I believe you need the same 
number of columns in your file as your table. So if you want FTS to be 
null, append \N to the output, e.g.

SELECT session_id || '\t' || poster_name || '\t' || time || '\t' || 
post_number || '\t\N'
  	FROM chat_post
  	ORDER BY time

Also, you should probably leave the foreign key reference off the table 
and add it after you load the data.

Hope this helps,

Joe




view thread (10+ messages)  latest in thread

Message-ID: <3CB87B30.1010203@joeconway.com>
Permalink:  ../3CB87B30.1010203@joeconway.com/
Also on:    postgresql.org/message-id/3CB87B30.1010203@joeconway.com

 · 

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: mail@joeconway.com, nandrews@investsystems.co.uk, pgsql-general@postgresql.org
  Subject: Re: COPY performance
  In-Reply-To: <3CB87B30.1010203@joeconway.com>
  References: <Pine.LNX.4.21.0204131840360.3278-100000@ponder.fairway2k.co.uk> <3CB87B30.1010203@joeconway.com>

* 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