Re: Foreign Key Deadlocking - Mailing list pgsql-performance

From Csaba Nagy
Subject Re: Foreign Key Deadlocking
Date
Msg-id 1176992622.16187.97.camel@coppola.muc.ecircle.de
Whole thread Raw
In response to Re: Foreign Key Deadlocking  (Alvaro Herrera <alvherre@commandprompt.com>)
List pgsql-performance
> A frequently mentioned approach to avoid the point of contention is to
> have a "totals" record and have the triggers insert "deltas" records; to
> get the sum, add them all.  Periodically, take the deltas and apply them
> to the totals.

This is what we do here too. There is only one exception to this rule,
in one case we actually need to have the inserted records and the
updated parent in one transaction for data consistency, in that case the
delta approach won't work... we didn't find any other solution to that
except patching postgres not to lock the parent keys at all, which has
it's own problems too (occasional breakage of the foreign key
relationship when the parent is deleted and a child still slips in, but
this is very rare in our case not to cause problems which cannot be
cleaned up with relative ease - not to mention that there could be other
problems we didn't discover yet or our usage patterns are avoiding).

Cheers,
Csaba.



pgsql-performance by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Foreign Key Deadlocking
Next
From: "Michael Dengler"
Date:
Subject: how to output column names