From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: ALTER TABLE ... DETACH PARTITION just sitting there
Date: Tue, 29 Jun 2021 03:50:26 +0200
Message-ID: <ea4f988b8853006a01b0fa990d0e5386e2a21fa2.camel@cybertec.at> (raw)
In-Reply-To: <bc71ab12-ee81-5f37-badf-22554cdc17ff@gmail.com>
References: <a9cedc4d-ffe8-01a5-bd09-5fe039b44075@gmail.com>
<342541.1624914966@sss.pgh.pa.us>
<bc71ab12-ee81-5f37-badf-22554cdc17ff@gmail.com>
On Mon, 2021-06-28 at 16:52 -0500, Ron wrote:
> On 6/28/21 4:16 PM, Tom Lane wrote:
> > Ron <ronljohnsonjr@gmail.com> writes:
> > > AWS RDS Postgresql 12.5.
> > > We've got a table partitioned by month range (FOR VALUES FROM ('2011-07-01')
> > > TO (2011-08-01')), and I've been detaching partitions from oldest to newest,
> > > one at a time. Whenever it's failed due to a FK constraint (and there are
> > > many of them!), I dropped the "same month" partition from TABLE_B, and then
> > > returned and dropped the partition from TABLE_A.
> > > But now, after 17 dropped partitions it's just sitting there on "ALTER TABLE
> > > table_a DROP PARTITION table_a_p2011_07;" I'm the only user on this test
> > > instance, and validated that nothing else is blocking me.
> > > Are the FK validations what's causing the apparent "hang"? (EXPLAIN ALTER
> > > TABLE... does not work.)
> >
> > Perhaps the corresponding TABLE_B partition lacks an index on the
> > referencing column? I've not looked at how this particular case
> > is implemented, but typically, lack of such an index is fine
> > until you try to delete PK-side rows.
>
> There are seven FK constraints, all in the format of (field_1, field_2).
> Two referenced table have a supporting index on both columns, and five have
> a supporting index on only field_1.
Those five foreign keys that are not fully indexed may well be your problem.
Yours,
Laurenz Albe
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: laurenz.albe@cybertec.at, ronljohnsonjr@gmail.com
Subject: Re: ALTER TABLE ... DETACH PARTITION just sitting there
In-Reply-To: <ea4f988b8853006a01b0fa990d0e5386e2a21fa2.camel@cybertec.at>
References: <a9cedc4d-ffe8-01a5-bd09-5fe039b44075@gmail.com> <342541.1624914966@sss.pgh.pa.us> <bc71ab12-ee81-5f37-badf-22554cdc17ff@gmail.com> <ea4f988b8853006a01b0fa990d0e5386e2a21fa2.camel@cybertec.at>
* 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