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 1qKjVF-001Oyr-4G for pgsql-general@arkaria.postgresql.org; Sat, 15 Jul 2023 17:56:21 +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 1qKjVD-002zsf-Jl for pgsql-general@arkaria.postgresql.org; Sat, 15 Jul 2023 17:56:19 +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 1qKjVD-002zsW-9O for pgsql-general@lists.postgresql.org; Sat, 15 Jul 2023 17:56:19 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qKjVA-000eg1-Je for pgsql-general@lists.postgresql.org; Sat, 15 Jul 2023 17:56:18 +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 36FHuDv73614138; Sat, 15 Jul 2023 13:56:13 -0400 From: Tom Lane To: Boris Sagadin cc: "pgsql-generallists.postgresql.org" Subject: Re: pg_restore mostly idle on restoring a large number of tables In-reply-to: References: Comments: In-reply-to Boris Sagadin message dated "Thu, 13 Jul 2023 09:41:11 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3614136.1689443773.1@sss.pgh.pa.us> Date: Sat, 15 Jul 2023 13:56:13 -0400 Message-ID: <3614137.1689443773@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Boris Sagadin writes: > restoring a 1.5TB database with about 800k tables on i3.4xlarge AWS > instace, PgSQL V12.15 on Ubuntu. > Running pg_restore with -j 16, I noticed the pg_restore is busy for an hour > or so with IO at 80%+ and then most of processes start idling and only a > few doing some work, disk IO at 1-2%, pg_stat_activity is mostly idle, same > goes for CPU, and this state proceeds for further 6 hours, disk space > increases very slowly. Yeah, this seems like a performance bug in pg_restore, per analysis at [1]. Until somebody gets around to doing something about that, I'd counsel not bothering with parallelized restore for this many tables. If the tables are mostly small, it'd likely be more useful to use --single-transaction mode; though you'd have to make sure that max_locks_per_transaction is set high enough to allow creating all those tables in one transaction. regards, tom lane [1] https://www.postgresql.org/message-id/3612876.1689443232%40sss.pgh.pa.us