Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ly2tX-0007Gf-Ef for pgsql-general@arkaria.postgresql.org; Tue, 29 Jun 2021 01:50:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ly2tV-0001R3-S4 for pgsql-general@arkaria.postgresql.org; Tue, 29 Jun 2021 01:50:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ly2tV-0001Qv-Ex for pgsql-general@lists.postgresql.org; Tue, 29 Jun 2021 01:50:33 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ly2tR-0000UU-OM for pgsql-general@postgresql.org; Tue, 29 Jun 2021 01:50:32 +0000 Received: by mail-wm1-x32e.google.com with SMTP id j11-20020a05600c1c0bb02901e23d4c0977so723939wms.0 for ; Mon, 28 Jun 2021 18:50:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=AMngMJbGGCxgl5sLw7gexmV+hV9Bu/AW0ZzZS5JO0/0=; b=Ed4CU55SDzMZmhoJ+OWHYtUD9y1Y93Txgl94SJf+YxIhVCEIpBfGKMD7CXWk3n2l4K eSVNonF5GKyP1lH/Y2Sn2cM8wQ2fiASbR+XIqidTsMeGaqt9DaUSFlY7IDv2FP72E6SR 3GOZnLi5owxx67Hke7EADXiEw9Uft4A8NlUcHXxAgly1K5wYAoXz3UWIUWajwZsfxl7Z 7GcOGLIoSuD4n2koXaTBEP5uUXYWvYxmUoQQWOF5Fq2x0h+DzuZMhOj1x53bubgCgItB HtNuq0g+zyNzqy4KV3KTJYq/17Hfox+yraoUDSTEY330HFzBZsEBYNDxE2UNZiI6TsBU 6H9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=AMngMJbGGCxgl5sLw7gexmV+hV9Bu/AW0ZzZS5JO0/0=; b=EDTXJ8a9McpnLeMYB3sp+yFmBacfFaRte6mXeqn1mSWPklIQ97Nv4V2XOK3A6B46pW sDmo9wP8uMtOIWPVkAjzkZY0FI9K+hAjgNzUr+Dcryc2QTrC8JvCmiPrabXsT7lFrw2h hFep8r6zfrM6orGy2NDCbRrb/OBvIj0jQKAkyEO9VhH1v/NuercmY15KJpRWOPYW9Te0 SPoj6fRGmTiGSPkImXXXSPbg7tkpbbrx/aJwIq9m66uBTXao1WK6JjIarWWu3d6vqh3m fIYu8jjHTRbQyN7q4qLKZXwFuBmkB7OK51JnV7pEsaYbEee9o+UkvOm/bOBAC+iIwbra pu0Q== X-Gm-Message-State: AOAM532iXgN9cHj7tbVBLIrfRDJ+p3jlZYDQcjk1wYQ0JeqcdS2EFHEa EXYoTfj/xK99SEEgYXoEf7iLYw== X-Google-Smtp-Source: ABdhPJzGunxk5GuTUfBtGDNcSNIr2sOw5qneCZnst5Z9Tu/eM9n3Jq314yiH0jAHAkdfUNYdIsDS4Q== X-Received: by 2002:a1c:7510:: with SMTP id o16mr29566098wmc.137.1624931427111; Mon, 28 Jun 2021 18:50:27 -0700 (PDT) Received: from localhost.localdomain (178-190-180-170.adsl.highway.telekom.at. [178.190.180.170]) by smtp.gmail.com with ESMTPSA id o26sm14905772wmr.29.2021.06.28.18.50.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Jun 2021 18:50:26 -0700 (PDT) Message-ID: Subject: Re: ALTER TABLE ... DETACH PARTITION just sitting there From: Laurenz Albe To: Ron , "pgsql-general@postgresql.org" Date: Tue, 29 Jun 2021 03:50:26 +0200 In-Reply-To: References: <342541.1624914966@sss.pgh.pa.us> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2021-06-28 at 16:52 -0500, Ron wrote: > On 6/28/21 4:16 PM, Tom Lane wrote: > > Ron 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