Re: feeding big script to psql

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: Havasvölgyi Ottó <h(dot)otto(at)freemail(dot)hu>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: feeding big script to psql
Date: 2005-08-02 15:57:11
Message-ID: 1122998231.21793.11.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 2005-08-02 at 04:24, Havasvölgyi Ottó wrote:
> Tom,
>
> Thanks for the suggestion. I have just applied both switch , -f (I have
> applied this in the previous case too) and -n, but it becomes slow again. At
> the beginning it reads about 300 KB a second, and when it has read 1.5 MB,
> it reads only about 10 KB a second, it slows down gradually. Maybe others
> should also try this scenario. Can I help anything?

I be you've got an issue where a seq scan on an fk field or something
works fine for the first few thousand rows. At some point, pgsql should
switch to an index scan, but it just doesn't know it.

Try wrapping every 10,000 or so inserts with

begin;
<insert 10,000 rows>
commit;
analyze;
begin;
rinse, wash repeat.

You probably won't need an analyze after the first one though.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dan Armbrust 2005-08-02 16:05:48 Force PostgreSQL to use indexes on foreign key lookups - Was: Slow Inserts on 1 table?
Previous Message littlebutty 2005-08-02 15:52:12 Re: PostgreSQL vs. MySQL