From: | Michel Pelletier <pelletier(dot)michel(at)gmail(dot)com> |
---|---|
To: | Samuel Nelson <valczir(dot)darkvein(at)gmail(dot)com> |
Cc: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: CASCADE/fkey order |
Date: | 2020-07-24 16:42:04 |
Message-ID: | CACxu=vL57HC3nCvbUZUeOJj2_rku38xgOQ_SatJ-8_y_H4qwxg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
You can benchmark your scenario with and without constraint using a tool
like nancy:
https://gitlab.com/postgres-ai/nancy
it lets you A/B test different configurations with your own scenarios or
using pgbench synthetic workloads.
-Michel
On Wed, Jul 22, 2020 at 9:27 AM Samuel Nelson <valczir(dot)darkvein(at)gmail(dot)com>
wrote:
> I checked, and changing the `bazinga_foo_bar` constraint to:
>
> alter table bazinga add constraint bazinga_foo_bar foreign key (foo_id,
> bar_id) references foo_bar (foo_id, bar_id) deferrable initially deferred;
>
> 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?
>
> Our resident ex-Oracle DBA said that deferred constraints used to be
> heavily recommended against, but he also admitted that he hasn't kept up
> with that in the past 10 years.
>
> -Sam
>
> https://github.com/nelsam
>
> "As an adolescent I aspired to lasting fame, I craved factual certainty,
> and
> I thirsted for a meaningful vision of human life -- so I became a
> scientist.
> This is like becoming an archbishop so you can meet girls."
> -- Matt Cartmill
>
>
> On Wed, Jul 22, 2020 at 10:31 AM David G. Johnston <
> david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>
>> On Wed, Jul 22, 2020 at 8:24 AM Samuel Nelson <valczir(dot)darkvein(at)gmail(dot)com>
>> wrote:
>>
>>> Is there a way to force the delete to cascade to tables in a specific
>>> order?
>>>
>>
>> No really, but you can defer constraint checking.
>>
>> https://www.postgresql.org/docs/12/sql-set-constraints.html
>>
>> David J.
>>
>>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2020-07-24 19:14:04 | Re: Row estimates for empty tables |
Previous Message | Vasu Madhineni | 2020-07-24 16:38:50 | TDE implementation in postgres which is in docker container |