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 1tvLOO-003iHw-Sy for pgsql-performance@arkaria.postgresql.org; Thu, 20 Mar 2025 19:17:24 +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 1tvLON-007DMo-Go for pgsql-performance@arkaria.postgresql.org; Thu, 20 Mar 2025 19:17:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tvLON-007DMc-1K for pgsql-performance@lists.postgresql.org; Thu, 20 Mar 2025 19:17:23 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tvLOL-000BcR-0i for pgsql-performance@lists.postgresql.org; Thu, 20 Mar 2025 19:17:21 +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 52KJHH7L1095775; Thu, 20 Mar 2025 15:17:17 -0400 From: Tom Lane To: Dimitrios Apostolou cc: pgsql-performance@lists.postgresql.org Subject: Re: parallel pg_restore blocks on heavy random read I/O on all children processes In-reply-to: <6bd16bdb-aa5e-0512-739d-b84100596035@gmx.net> References: <6bd16bdb-aa5e-0512-739d-b84100596035@gmx.net> Comments: In-reply-to Dimitrios Apostolou message dated "Wed, 19 Mar 2025 19:46:58 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1095773.1742498237.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 20 Mar 2025 15:17:17 -0400 Message-ID: <1095774.1742498237@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Dimitrios Apostolou writes: > I noticed the weird behaviour that doing a pg_restore of a huge database > dump, leads to constant read I/O (at about 15K IOPS from the NVMe drive > that has the dump file) for about one hour. I believe it happens with > any -j value>=3D2. > In particular, I get output like the following in the pg_restore log, on= ly > a few seconds after running it: > pg_restore: launching item 12110 TABLE DATA yyy > pg_restore: processing data for table "public.yyy" > [ long pause ...] > pg_restore: finished item 12110 TABLE DATA yyy I am betting that the problem is that the dump's TOC (table of contents) lacks offsets to the actual data of the database objects, and thus the readers have to reconstruct that information by scanning the dump file. Normally, pg_dump will back-fill offset data in the TOC at completion of the dump, but if it's told to write to an un-seekable output file then it cannot do that. > And here is the pg_dump command which has created the dump file, execute= d > on PostgreSQL 16. > pg_dump -v --format=3Dcustom --compress=3Dzstd --no-toast-compression $= DBNAME | $send_to_remote_storage Yup, writing the output to a pipe would cause that ... > What do you think causes this? Is it something that can be improved? I don't see an easy way, and certainly no way that wouldn't involve redefining the archive format. Can you write the dump to a local file rather than piping it immediately? regards, tom lane