Re: Rapidly decaying performance repopulating a large table - Mailing list pgsql-general

From Tom Lane
Subject Re: Rapidly decaying performance repopulating a large table
Date
Msg-id 27980.1208902255@sss.pgh.pa.us
Whole thread Raw
In response to Re: Rapidly decaying performance repopulating a large table  ("David Wilson" <david.t.wilson@gmail.com>)
Responses Re: Rapidly decaying performance repopulating a large table  ("David Wilson" <david.t.wilson@gmail.com>)
List pgsql-general
"David Wilson" <david.t.wilson@gmail.com> writes:
> Foreign keys are definitely indexed (actually referencing a set of
> columns that the foreign table is UNIQUE on).

Are you loading any tables that are the targets of foreign key
references from other tables being loaded?  If so, I'd bet on
Scott's theory being correct with respect to the plans for checks
of those FK constraints.  The COPY itself hasn't got any plan,
and inserting rows into a table should be constant-time in itself,
so it seems to me there are only two possibilities for a progressive
slowdown:

* the cost of updating the indexes, which for standard btree indexes
ought to grow at about log(N) when there are already N entries

* bad plans in either foreign-key triggers or user-defined triggers
attached to the tables.

You failed to mention what PG version this is (tut tut) but if it's
less than 8.3 then ANALYZE alone won't fix bad plans in triggers;
you'd need to analyze and then start a fresh database session.

You said that you don't need to have the FK constraints present,
so I'd strongly suggest trying it without ...

            regards, tom lane

pgsql-general by date:

Previous
From: Erik Jones
Date:
Subject: Re: Rapidly decaying performance repopulating a large table
Next
From: Jeff Davis
Date:
Subject: Re: How to modify ENUM datatypes?