pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Worky Workerson <worky.workerson@gmail.com>
To: Merlin Moncure <mmoncure@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Best COPY Performance
Date: Mon, 23 Oct 2006 11:10:19 -0400
Message-ID: <ce4072df0610230810t5d66bbb8xf1e9c0ed71b6b6c0@mail.gmail.com> (raw)
In-Reply-To: <b42b73150610201811m84369f7kc7d58b39aed3ad73@mail.gmail.com>
References: <ce4072df0610201305u7836dc7bn437ec0aaf1c3e25f@mail.gmail.com>
	<b42b73150610201811m84369f7kc7d58b39aed3ad73@mail.gmail.com>

> > I am most interested in loading two tables, one with about 21 (small)
> > VARCHARs where each record is about 200 bytes, and another with 7
> > INTEGERs, 3 TIMESTAMPs, and 1 BYTEA where each record is about 350
> > bytes.
>
> indexes/keys?  more memory for sorting during index creation can have
> a dramatic affect on bulk insert performance.  check for pg_tmp
> folders popping up during copy run.

The only index on load is a single IP4 btree primary key, which I
figure should function about like an INTEGER.

> for table light on indexes, 10-15k for copy is pretty poor.  you can
> get pretty close to that with raw inserts on good hardware. I would
> suggest configuirng your perl script to read from stdin and write to
> stdout, and pipe it to psql using copy from stdin.  then just
> benchmark your perl script redirecting output to a file.

So simple and hadn't thought of that ... thanks.  When I pre-create a
COPY file, I can load it at about 45K inserts/sec (file was 1.8GB or
14.5 million records in 331 seconds), which looks like its about 5.5
MB/s.  I'm loading from a local 15K SCSI320 RAID10 (which also
contains the PG log files) to a 10K SCSI320 RAID10 on an FC SAN.  Does
this look more consistent with "decent" performance, or should I go
looking into some hardware issues i.e. SAN configuration?  I've
currently got several hats including hardware/systems/security admin,
as well as DBA and programmer, and my SAN setup skills could
definitely use some more work.

Hardware aside, my perl can definitely use some work, and it seems to
be mostly the CSV stuff that I am using, mostly for convenience.  I'll
see if I can't redo some of that to eliminate some CSV processing, or,
barring that, multithread the process to utilize more of the CPUs.
Part of the reason that I hadn't used psql in the first place is that
I'm loading the data into partitioned tables, and the loader keeps
several COPY connections open at a time to load the data into the
right table.  I guess I could just as easily keep several psql pipes
open, but it seemed cleaner to go through DBI.



view thread (52+ messages)  latest in thread

Message-ID: <ce4072df0610230810t5d66bbb8xf1e9c0ed71b6b6c0@mail.gmail.com>
Permalink:  ../ce4072df0610230810t5d66bbb8xf1e9c0ed71b6b6c0@mail.gmail.com/
Also on:    postgresql.org/message-id/ce4072df0610230810t5d66bbb8xf1e9c0ed71b6b6c0@mail.gmail.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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: worky.workerson@gmail.com, mmoncure@gmail.com
  Subject: Re: Best COPY Performance
  In-Reply-To: <ce4072df0610230810t5d66bbb8xf1e9c0ed71b6b6c0@mail.gmail.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