Re: Foreign key slows down copy/insert

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: Richard van den Berg <richard(dot)vandenberg(at)trust-factory(dot)com>, Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Foreign key slows down copy/insert
Date: 2005-04-14 15:05:45
Message-ID: 742.1113491145@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> writes:
> ... At some point, if we can work out how to do all the semantics
> properly, it'd probably be possible to replace the insert type check with
> a per-statement check which would be somewhere in between. That requires
> access to the affected rows inside the trigger which I don't believe is
> available currently.

Not necessarily. It occurs to me that maybe what we need is "lossy
storage" of the trigger events. If we could detect that the queue of
pending checks for a particular FK is getting large, we could discard
the whole queue and replace it with one entry that says "run the
wholesale check again when we are ready to fire triggers". I'm not
sure how to detect this efficiently, though --- the trigger manager
doesn't presently know anything about FKs being different from
any other kind of trigger.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Richard van den Berg 2005-04-14 15:08:22 Re: Foreign key slows down copy/insert
Previous Message Mohan, Ross 2005-04-14 15:02:27 Re: How to improve db performance with $7K?