Skip site navigation (1) Skip section navigation (2)

Re: Best COPY Performance

From: "Worky Workerson" <worky(dot)workerson(at)gmail(dot)com>
To: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Best COPY Performance
Date: 2006-10-23 15:10:19
Message-ID: ce4072df0610230810t5d66bbb8xf1e9c0ed71b6b6c0@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-performance
> > 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.

In response to

Responses

pgsql-performance by date

Next:From: Luke LonerganDate: 2006-10-23 15:11:00
Subject: Re: Best COPY Performance
Previous:From: Alvaro HerreraDate: 2006-10-23 13:50:11
Subject: Re: Index on two columns not used

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group