pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: scott.marlowe <scott.marlowe@ihs.com>
To: Jose Vicente Nunez Z <josevnz@newbreak.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-admin@postgresql.org
Subject: Re: Inserting 26 million rows takes 8 hours, how to
Date: Tue, 16 Sep 2003 10:04:27 -0600 (MDT)
Message-ID: <Pine.LNX.4.33.0309160952250.4245-100000@css120.ihs.com> (raw)
In-Reply-To: <1063726066.5407.46.camel@linux0037>

On 16 Sep 2003, Jose Vicente Nunez Z wrote:

> Tom,
> 
> 
> On Tue, 2003-09-16 at 10:44, Tom Lane wrote:
> > Jose Vicente Nunez Z <josevnz@newbreak.com> writes:
> > > For that i'm using the PostgreSQL copy tool, but the problem is that is
> > > taking almost 9 hours to load the data:
> > 
> > Hmm, 889 rows/second doesn't sound that bad, considering that you've
> > given us no data about the hardware you're running on.  In particular,
> > what's your disk setup?
> 
> My fault, i should provide more information about my setup.
> 
> I got two ATA disks (one for PostgreSQL, the other for the data files).
> The box is a Pentium III 1.3Ghz, dual CPU with 2 GB of RAM. One disk is
> 30 GB, the other is 40GB.
> 
> As you can see is not state of the art harware, but for development
> purposes i should get a decent performance (only one or two applications
> will be accessing the server to do some data mining).
> 
> > 
> > But at any rate, the only bottlenecks I could think of for a COPY
> > command are:
> > 
> > 1. Data conversion.  This would depend on the column datatypes of the
> > table, which you didn't tell us.
> > 
> create table mytable
> ( 
> 	 a         varchar(20) not null,
> 	 b         varchar(20) not null,
> 	 c         varchar(20) not null,
> 	 d         char(6),
> 	 f         int null,
> 	 g         float not null,
> 	 h         float not null
> )
> 
> Data conversions shouldn't be that complicated, isn't it?
> 
> > 2. Index updating.  This would depend on the indexes on the table,
> > which you didn't tell us.
> 
> I had one index and dropped it for the load. Also i turn of the 'fsync'
> flag (fsync=false) and now the load time is only 15 minutes!. But then
> recreating the original index takes forever:
> 
> create  index myindex on mytable ( a, b, c );

Are you sure this is the type of index you want?  Keep in mind postgresql 
won't use this index for queries like:

select * from mytable where b='abc';

or

select * from mytable where a='%abc%';

but only for queries that invoke a, then b, then c, and only with left 
anchored text.

select * from mytable where a='abc' and b='def';

will work.  you might want to look at using the tsearch engine just 
updated for 7.4.x for this kind of thing, or just running seq scans with a 
whole lot of shared_buffers to hold your data.

Cranking shared_buffers up to 1000 to 20000 or so should help.  Note that 
there's a point of diminishing returns for certain queries with large 
shared_buffers where buffer management costs more than having the data in 
the buffer.  For what you're doing, however, larger may well be better.

Oh, and don't forget to vacuum and analyze...




view thread (5+ messages)

Message-ID: <Pine.LNX.4.33.0309160952250.4245-100000@css120.ihs.com>
Permalink:  ../Pine.LNX.4.33.0309160952250.4245-100000@css120.ihs.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.33.0309160952250.4245-100000@css120.ihs.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: scott.marlowe@ihs.com, josevnz@newbreak.com, tgl@sss.pgh.pa.us
  Subject: Re: Inserting 26 million rows takes 8 hours, how to
  In-Reply-To: <Pine.LNX.4.33.0309160952250.4245-100000@css120.ihs.com>
  References: <1063726066.5407.46.camel@linux0037> <Pine.LNX.4.33.0309160952250.4245-100000@css120.ihs.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