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 1twktt-00HMo0-Gd for pgsql-performance@arkaria.postgresql.org; Mon, 24 Mar 2025 16:43:45 +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 1twkts-006b5D-2W for pgsql-performance@arkaria.postgresql.org; Mon, 24 Mar 2025 16:43:44 +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 1twktr-006b54-OE for pgsql-performance@lists.postgresql.org; Mon, 24 Mar 2025 16:43:43 +0000 Received: from mout.gmx.net ([212.227.17.22]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1twktq-000tKg-02 for pgsql-performance@lists.postgresql.org; Mon, 24 Mar 2025 16:43:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1742834620; x=1743439420; i=jimis@gmx.net; bh=tUCqgaXK64vKh/B8zcCVwU9OsHBeTbt+SjbEGPcoK4k=; h=X-UI-Sender-Class:Date:From:To:cc:Subject:In-Reply-To:Message-ID: References:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=OdaD4rtzGyzznpTQlkIXJyHwCNw9BKrH42n2x7lRzEApcagoGbN1BQVIudepkEIA uh9OJxDjF+2Qv7Jo1yLtp/q0RUkwB+/5pFMBAZ8E5D4f2QbS2dRG0n3V+4jitLfvF 022DxxIvh2+Wt4Lx/i3OVZFcdpdqYV01WGshWzw4JhCotZ3wisOvSXDTK9uwapFU9 CpjwJ+/iPBiUqgR44zxLHtF6UwR5HyYVssVNmGXIKnoqAAExDyFJiVy4+seATGErf JhR2PdTqy+A94i1VTAYc0Xe4wxcmRBKHAH/UpvTTRyvPKx8wN2WxPiW1nrqV+CuyP XiSEE+Jpx/U89VjCgw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [10.9.70.81] ([185.55.106.54]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MWRVb-1tdL9c3fGF-00NiXI; Mon, 24 Mar 2025 17:43:40 +0100 Date: Mon, 24 Mar 2025 17:43:38 +0100 (CET) From: Dimitrios Apostolou To: Tom Lane 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: <556498.1742744802@sss.pgh.pa.us> Message-ID: <3764bde7-ca09-a8a3-489c-0166f772245d@gmx.net> References: <6bd16bdb-aa5e-0512-739d-b84100596035@gmx.net> <1095774.1742498237@sss.pgh.pa.us> <556498.1742744802@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Provags-ID: V03:K1:XwoLkTE8rSHZ8h4ELoauz24Q662fwZF8pXqU2NLV9RrCahVCnVd AnNdhyoqF2tyGrMpHnjEGvPsiVQbVuju2LK6KGmhJUx+GVRj+SnxCLnQRXpeQhnu2eN+eUW vElcLDfHeqJJsigzWevCQD5ukduQUvPokEQ++LKpmYThIf3YvX9tE61Ya2jgmKBv8ZNGCXu KHVu9uXKKKWprMnY4N/ug== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:mLScCSOQiw8=;YEzh5tTpVLq7SHseNKPSbQ09MRi tQ6ZxbNkfNn2e37XD2NPSf1YHXdOm0N7j9JZwE6DljdJniKPH4qZ0pFAGvuUEyCM40N20yqEj AVqPfw787cVUSu08WDs0Lrkoi2Ybmd9oevvuCaQ4GNWKPINzgqE/zA3ysWLn0uEpoJFDEtUgA nt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oRA9YLE42Aq8dCN7tCaG946tCT2G XoWAHTcXVwAw+Uab4RBd1sYm6156Bxd0zP+Qii0am66zN2VdencopuTp15APOap2ZdJRJ8EbN f7Qutzl6w1ud1Q5QBxXrkKoBVJ9ew40+7tDC/wVr1MoNAJ2sp2EQoinoKrFGn06qI3tjCgW7L h9WCdBh0ZjRmQzTem9WHZLL7+pvfrLlMmJRW08rjIeaCF4ULAfTSAhQvXt530f3I5tGDMpxIo fECHAzr9Zs8d8Q1oclLljzWKxEzo= Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, 23 Mar 2025, Tom Lane wrote: > Dimitrios Apostolou writes: >> On Thu, 20 Mar 2025, Tom Lane wrote: >>> 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. > >> Further questions: > >> * The seeking pattern in pg_restore seems non-sensical to me: reading 4= K, >> jumping 8-12K, repeat for the whole file? Consuming 15K IOPS for an >> hour. /Maybe/ something to improve there... Where can I read more ab= out >> the format? > > It's reading data blocks (or at least the headers thereof), which have > a limited size. I don't think that size has changed since circa 1999, > so maybe we could consider increasing it; but I doubt we could move > the needle very far that way. If it could be substantially increased then it would cut down the number of seeks by a big factor and definitely make a difference. But it would have a negative impact on the size of small backups? However, I would have expected the kernel to handle this reading-seeking pattern better: The 4K read() should cause a big pre-fetch (read-ahead) to cover the next seek and read. Not sure why I don't see it happening, it's a rather typical setup (NVMe SSD with ext4 fs on Linux 6.11). As a workaround, pg_restore could sequentially read() the whole archive to construct the TOC, instead of jumping around. I'm a bit split on this one, as it would be much faster on the compressed archive (~800GB) but not that much on the uncompressed one (>5TB). I'm also under the impression that all the pg_restore child processes are doing the same thing: seeking+reading the whole file, each for their own sake. Can you verify or disprove? Thank you for the detailed response. Dimitris