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 1pWgF5-0000w6-9Z for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Feb 2023 16:20:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pWgF3-0004fu-Je for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Feb 2023 16:20:45 +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 1pWgF3-0004fk-AO for pgsql-hackers@lists.postgresql.org; Mon, 27 Feb 2023 16:20:45 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pWgEy-0006P5-GL for pgsql-hackers@lists.postgresql.org; Mon, 27 Feb 2023 16:20:44 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 31RGKYn3369735; Mon, 27 Feb 2023 11:20:34 -0500 From: Tom Lane To: Robert Haas cc: Andrew Dunstan , Alvaro Herrera , David Rowley , Peter Geoghegan , pgsql-hackers@lists.postgresql.org, Andrew Subject: Re: pg_dump versus hash partitioning In-reply-to: References: <1376149.1675268279@sss.pgh.pa.us> <1412538.1675283692@sss.pgh.pa.us> <1425446.1675291093@sss.pgh.pa.us> <1440373.1675299790@sss.pgh.pa.us> <1533086.1675349554@sss.pgh.pa.us> <1912821.1676402493@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Mon, 27 Feb 2023 10:50:42 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <369733.1677514834.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Mon, 27 Feb 2023 11:20:34 -0500 Message-ID: <369734.1677514834@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Robert Haas writes: > On Tue, Feb 14, 2023 at 2:21 PM Tom Lane wrote: >> This made me wonder if this could be a usable solution at all, but >> after thinking for awhile, I don't see how the claim about foreign key >> constraints is anything but FUD. pg_dump/pg_restore have sufficient >> dependency logic to prevent that from happening. I think we can just >> drop the "or perhaps ..." clause here, and tolerate the possible >> inefficiency as better than failing. > Right, but isn't that dependency logic based around the fact that the > inserts are targeting the original partition? Like, suppose partition > A has a foreign key that is not present on partition B. A row that is > originally in partition B gets rerouted into partition A. It must now > satisfy the foreign key constraint when, previously, that was > unnecessary. Well, that's a user error not pg_dump's fault. Particularly so for hash partitioning, where there is no defensible reason to make the partitions semantically different. There could be a risk of a timing problem, namely that parallel pg_restore tries to check an FK constraint before all the relevant data has arrived. But in practice I don't believe that either. We load all the data in "data" phase and then create indexes and check FKs in "post-data" phase, and I do not believe that parallel restore weakens that separation (because it's enforced by a post-data boundary object in the dependencies). regards, tom lane