Re: CASCADE/fkey order - Mailing list pgsql-general

From David G. Johnston
Subject Re: CASCADE/fkey order
Date
Msg-id CAKFQuwbZma4+i43RZDxJHi7uay14WNditYJ4Jf3vjTM5zAYJ_w@mail.gmail.com
Whole thread Raw
In response to Re: CASCADE/fkey order  (Samuel Nelson <valczir.darkvein@gmail.com>)
List pgsql-general
On Wed, Jul 22, 2020 at 9:03 AM Samuel Nelson <valczir.darkvein@gmail.com> wrote:
seems to fix it to work as we were expecting.  Is that particularly costly?  Should I only set the constraint to be deferred when we really need it?  Would it be more efficient to perform the deletes explicitly within a transaction rather than relying on the cascades and deferring that one constraint?

I don't know.  I tend to go with only deferring the check if the specific transaction requires it.  If there are no issues I would presume that checking at the end would be more efficient.  But if there are problems you could end up performing unnecessary work.  Memory consumption probably increases as well since constraint related information cannot be discarded as each command completes but must be kept around for the eventual validation.

David J.

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Slow or Cannot Connect to PostgreSQL Instance Service on Windows 10
Next
From: "David G. Johnston"
Date:
Subject: Re: How to create function returning numeric from string containing percent character