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 1lxzBG-0000Du-FR for pgsql-general@arkaria.postgresql.org; Mon, 28 Jun 2021 21:52:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lxzBF-00040A-6v for pgsql-general@arkaria.postgresql.org; Mon, 28 Jun 2021 21:52:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lxzBE-000402-Ru for pgsql-general@lists.postgresql.org; Mon, 28 Jun 2021 21:52:36 +0000 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lxzBB-0000n1-Lx for pgsql-general@postgresql.org; Mon, 28 Jun 2021 21:52:35 +0000 Received: by mail-oi1-x234.google.com with SMTP id u11so23821067oiv.1 for ; Mon, 28 Jun 2021 14:52:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=eDlmZh3ip+Odp5JeXD7viaiNx1Zz7pPzEsj9FhYXzrk=; b=MfRUo85WV+2Vboxlfc/mNAwNBsfXONizw+hOp69uvFnP9wWWkkxHHawxNvzFLJEfgE 6JE8dak3k1+bdlexb83q6mWqn7HSMMFX2SeIPOUvIHOpXG1vY1h4qXoN1GXTHIlIRja7 PkIAQ1xONYJ7ZyQc0UT0iqvRWuhil+rDFEIDc2hI76FYKNAuYGie/Zt2yg7+IqYLVLLA LeB1T6KaW2MwKPtiVgM1lp3Z3KPJiKyqTZHla8PoEU4XNYJcFC0ZQcLAhN2MW60CtMt/ dbiV81/Um1NjlEHcnMVlX1fhQUnQyf0aXmvYLQOcRoKRFuqqbssB69dJtdntObxsZ1D1 IYVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=eDlmZh3ip+Odp5JeXD7viaiNx1Zz7pPzEsj9FhYXzrk=; b=QJqbHVAHuxJAqk95tkInz3re1iSezNncxuO8SbV0W+H94L0URTFuV3N/Sr9E2SFzb3 nDeaXUMWGZid8ri21dUI4xyPwuCgD+UR98rtp+bDO0GBJgsDC5FNhP3ImTjeu82qq7dt BfKCjVHzI+nLRJUzZBmeZGXHPXeclabudND4C7tExbCAFIJR8tB9cOHkN/q8KmMhUt0l xW7ou890PIWN9nZXmly+5+cvL4xbbj6Qv6STH3ep8tTwWN9nz6MLuBAjpVg+w83s91hY ziCKk4igpnnP0DEmdrtLe4o61nXMm9JQbRJtGjvexo0JFt6CcSm3r8AVBzjoUUVNHe5p qH9g== X-Gm-Message-State: AOAM532xJDT0ndgpPNv9YOk3erPW40n/JoKxXWJ4w+pkTByTBMjaE/Y0 WFEfRc6CKnO7ekFWqn6la96uOXks9g2txw== X-Google-Smtp-Source: ABdhPJxTzojsAhgs+2tco5NgRtQAQMuHZVd3Hhr0MtFUO2vQzejvE2Ak7p4Wcin85AhfQIfa/OVcFA== X-Received: by 2002:a05:6808:98e:: with SMTP id a14mr19180855oic.139.1624917150727; Mon, 28 Jun 2021 14:52:30 -0700 (PDT) Received: from [192.168.88.10] (ip174-67-141-204.no.no.cox.net. [174.67.141.204]) by smtp.googlemail.com with ESMTPSA id 15sm3167559otd.4.2021.06.28.14.52.29 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Jun 2021 14:52:30 -0700 (PDT) Subject: Re: ALTER TABLE ... DETACH PARTITION just sitting there To: "pgsql-general@postgresql.org" References: <342541.1624914966@sss.pgh.pa.us> From: Ron Message-ID: Date: Mon, 28 Jun 2021 16:52:28 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <342541.1624914966@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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. -- Angular momentum makes the world go 'round.