From: Jehan-Guillaume de Rorthais <jgdr@dalibo.com>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: FK violation in partitioned table after truncating a referenced partition
Date: Fri, 7 Feb 2020 19:22:57 +0100
Message-ID: <20200207192257.1145eadd@firost> (raw)
In-Reply-To: <20200207172751.GA26691@alvherre.pgsql>
References: <20200207171933.77aaaba6@firost>
<20200207172751.GA26691@alvherre.pgsql>
On Fri, 7 Feb 2020 14:27:51 -0300
Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> On 2020-Feb-07, Jehan-Guillaume de Rorthais wrote:
>
> > Maybe I would just add:
> >
> > /*
> > * If this constraint has a parent constraint which we have not seen
> > * yet, keep track of it for the second loop, below.
> > + * Tracking parent constraint allows to climb up to the top-level
> > + * level constraint and look for all possible relation referencing
> > + * the partioned table.
> > */
>
> LGTM.
Added.
> BTW I was thinking that perhaps it would make sense to go up all levels
> at once when we see a "parented" constraint; this would avoid having to
> restart several times when there's N-levels partitioning. It might be
> an issue if pg_constraint is large, because, you see, there's a seqscan
> there!
Indeed. See v4 in attachment. It saves 3 seqscans during the whole tests we
added.
> (Maybe now's the time to add an index to confrelid, but of
> course only in master). This probably doesn't matter much normally
> because nobody uses that many partition levels ...
I have a colleague that enjoys experimenting with limits. But I'm not sure I'll
have feedback from him before next minor release (next week?).
Regards,
Attachments:
[text/x-patch] 0001-v4-Fix-TRUNCATE-on-a-partition-to-apply-CASCADE-to-part.patch (0B, ../20200207192257.1145eadd@firost/2-0001-v4-Fix-TRUNCATE-on-a-partition-to-apply-CASCADE-to-part.patch)
download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: jgdr@dalibo.com, alvherre@2ndquadrant.com, pgsql-bugs@lists.postgresql.org
Subject: Re: FK violation in partitioned table after truncating a referenced partition
In-Reply-To: <20200207192257.1145eadd@firost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox