Re: Foreign key slows down copy/insert - Mailing list pgsql-performance

From Tom Lane
Subject Re: Foreign key slows down copy/insert
Date
Msg-id 742.1113491145@sss.pgh.pa.us
Whole thread Raw
In response to Re: Foreign key slows down copy/insert  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Responses Re: Foreign key slows down copy/insert  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
List pgsql-performance
Stephan Szabo <sszabo@megazone.bigpanda.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

pgsql-performance by date:

Previous
From: "Mohan, Ross"
Date:
Subject: Re: How to improve db performance with $7K?
Next
From: Richard van den Berg
Date:
Subject: Re: Foreign key slows down copy/insert