Re: CASCADE/fkey order

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Samuel Nelson <valczir(dot)darkvein(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: CASCADE/fkey order
Date: 2020-07-22 22:36:51
Message-ID: CAKFQuwbZma4+i43RZDxJHi7uay14WNditYJ4Jf3vjTM5zAYJ_w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Jul 22, 2020 at 9:03 AM Samuel Nelson <valczir(dot)darkvein(at)gmail(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2020-07-22 22:44:59 Re: How to create function returning numeric from string containing percent character
Previous Message Adrian Klaver 2020-07-22 22:26:06 Re: Slow or Cannot Connect to PostgreSQL Instance Service on Windows 10