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 1n5xh0-00089W-6E for pgsql-admin@arkaria.postgresql.org; Fri, 07 Jan 2022 22:26: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 1n5xgy-0002xk-Lg for pgsql-admin@arkaria.postgresql.org; Fri, 07 Jan 2022 22:26:36 +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 1n5xgy-0002xa-6v for pgsql-admin@lists.postgresql.org; Fri, 07 Jan 2022 22:26:36 +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 1n5xgv-0001Wr-PW for pgsql-admin@postgresql.org; Fri, 07 Jan 2022 22:26:35 +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 207MQVfD1386277; Fri, 7 Jan 2022 17:26:31 -0500 From: Tom Lane To: Wells Oliver cc: pgsql-admin Subject: Re: pg_restore with --use-list and --jobs and depdendencies In-reply-to: References: Comments: In-reply-to Wells Oliver message dated "Fri, 07 Jan 2022 13:04:14 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1386275.1641594391.1@sss.pgh.pa.us> Date: Fri, 07 Jan 2022 17:26:31 -0500 Message-ID: <1386276.1641594391@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Wells Oliver writes: > Hi all: I just wanted to clarify something for myself: how does pg_restore > determine restore order if you're using a --use-list and --jobs parameters. > Given the concurrency of jobs and (assuming) it goes in order of what's in > the list, does it... well, does it sort out dependencies properly so data > is inserted that foreign keys need, etc? (1) The basic order of the restored items is what you say in the --list file, but it will start the next item as soon as (a) a worker is free and (b) all of that item's dependencies are complete (2) It will honor direct dependencies between restored items, ie not start B till A is done if B is shown as depending on A (3) I'm not too sure about indirect dependencies, ie if you have a situation where C depends on B depends on A and you ask for just A and C, that may end up with no dependency constraint delaying C. Which might be fine, or it might not; you'd need to be more specific about what you intend to skip. regards, tom lane