Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qNzLX-006VsS-I8 for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Jul 2023 17:27:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qNzLV-00CIsZ-1o for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Jul 2023 17:27:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qNzLU-00CIsR-M4 for pgsql-hackers@lists.postgresql.org; Mon, 24 Jul 2023 17:27:44 +0000 Received: from rock.pinaraf.info ([2001:41d0:fc0b:e300::1000]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qNzLS-0003r5-6y for pgsql-hackers@lists.postgresql.org; Mon, 24 Jul 2023 17:27:43 +0000 Received: from peanuts2.localnet (unknown [IPv6:2001:41d0:fc0b:e300:264b:feff:fe05:380b]) by rock.pinaraf.info (Postfix) with ESMTPSA id 4R8nDC0M5Rz20KR for ; Mon, 24 Jul 2023 19:27:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=pinaraf.info; s=rock; t=1690219659; bh=ctw5QWTzVwQhCRNUnNwmWIUx0gGxgzexJzKHf9Z+f1M=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PPl4vdcHZ3cVVsHP0FzLE+2UMw+q3YOmTFjcgn54YcA/R39x6FiIcidsWJoPxvWk4 YIBVuPmByVSYFwYDE6e8yIMlQpIw85ifsB87ZmMrKXZWwf/8UawQgETzujQ5235VMJ MhRgQLbFS3SxGJpfVL8h5LLb07YwCXPEnYUyin4MQAwCJZ4tYgngAgfQNGWNtdCIXb xpe6DCGyEtMBj0DbmyJUCro1evkxzS+szkawfIUTFkXZ+M6iFoTaj2ahnH38ADAsYM OEMV6NSYuj+ZyDolPhPTbHgqJ1+IIBxgHW3ZCoeErWk+jd9uDzdGAIMHfJ2xN80Vtt VvFKAlrXW5dAw== From: Pierre Ducroquet To: pgsql-hackers@lists.postgresql.org Subject: Re: Inefficiency in parallel pg_restore with many tables Date: Mon, 24 Jul 2023 19:27:36 +0200 Message-ID: <1903495.6tgchFWduM@peanuts2> In-Reply-To: <3612876.1689443232@sss.pgh.pa.us> References: <3612876.1689443232@sss.pgh.pa.us> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Saturday, July 15, 2023 7:47:12 PM CEST Tom Lane wrote: > I'm not sure how big a deal this is in practice: in most situations > the individual jobs are larger than they are in this toy example, > plus the initial non-parallelizable part of the restore is a bigger > bottleneck anyway with this many tables. Still, we do have one > real-world complaint, so maybe we should look into improving it. Hi For what it's worth, at my current job it's kind of a big deal. I was going to start looking at the bad performance I got on pg_restore for some databases with over 50k tables (in 200 namespaces) when I found this thread. The dump weights in about 2,8GB, the toc.dat file is 230MB, 50 120 tables, 142 069 constraints and 73 669 indexes. HEAD pg_restore duration: 30 minutes pg_restore with latest patch from Nathan Bossart: 23 minutes This is indeed better, but there is still a lot of room for improvements. With such usecases, I was able to go much faster using the patched pg_restore with a script that parallelize on each schema instead of relying on the choices made by pg_restore. It seems the choice of parallelizing only the data loading is losing nice speedup opportunities with a huge number of objects. patched pg_restore + parallel restore of schemas: 10 minutes Anyway, the patch works really fine as is, and I will certainly keep trying future iterations. Regards Pierre