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 1vAxJp-008ElB-S8 for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Oct 2025 21:21:29 +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 1vAxJo-004WPG-HF for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Oct 2025 21:21:27 +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 1vAxJo-004WP8-7v for pgsql-hackers@lists.postgresql.org; Mon, 20 Oct 2025 21:21:27 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vAxJk-003Igp-2g for pgsql-hackers@lists.postgresql.org; Mon, 20 Oct 2025 21:21:26 +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 59KLLGMd375563; Mon, 20 Oct 2025 17:21:16 -0400 From: Tom Lane To: Dimitrios Apostolou cc: Chao Li , Nathan Bossart , Thomas Munro , pgsql-hackers@lists.postgresql.org Subject: Re: [PATCH v4] parallel pg_restore: avoid disk seeks when jumping short distance forward In-reply-to: <9opr64ps-625r-667n-q19o-op35rs414n59@tzk.arg> References: <2edb7a57-b225-3b23-a680-62ba90658fec@gmx.net> <1282067.1744651649@sss.pgh.pa.us> <5ed51587-5a24-4d79-e36e-927620d0e3a2@gmx.net> <72d2c81b-a0fe-3d99-9dd4-0d771e6e673e@gmx.net> <1po8os49-r63o-2923-p37n-12698o1qn7p0@tzk.arg> <3515357.1760128017@sss.pgh.pa.us> <3698234.1760149336@sss.pgh.pa.us> <3686.1760232320@sss.pgh.pa.us> <717335.1760389672@sss.pgh.pa.us> <1306492.1760556110@sss.pgh.pa.us> <1518975.1760634070@sss.pgh.pa.us> <9opr64ps-625r-667n-q19o-op35rs414n59@tzk.arg> Comments: In-reply-to Dimitrios Apostolou message dated "Mon, 20 Oct 2025 20:40:27 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <375561.1760995276.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 20 Oct 2025 17:21:16 -0400 Message-ID: <375562.1760995276@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Dimitrios Apostolou writes: > Regarding the attached patch (rebased and edited commit message), it = > basically replaces seek(up to 1MB forward) with read(). The 1MB number = > comes a bit out of the top of my head. But tweaking it between 128KB and= = > 1MB wouldn't really change anything, given that the block size is now = > 128KB: The read() will always be chosen against the seek(). Do you know = > of a real-world case with block sizes >128KB? Yeah, with the recent changes I'd expect table data to pretty much always consist of blocks around 128K, unless the table is smaller than that of course. I experimented with this patch locally and came away not too impressed; it seems the results may be highly platform-dependent. In the interests of having a common benchmark case that's easy to replicate, here's precisely what I did: Use non-assert build of current HEAD (4bea91f21 at the moment). $ createdb bench $ time pgbench -i -s 10000 bench real 14m40.474s user 1m26.717s sys 0m5.045s $ psql bench ... bench=3D# create table zedtable(f1 int); CREATE TABLE bench=3D# insert into zedtable values(42); INSERT 0 1 bench=3D# \q $ time pg_dump -Fc --compress=3Dnone bench | cat >bench10000.dump real 7m48.969s user 0m36.334s sys 1m35.209s (At this -s value, the database occupies about 147G and the dump file about 95G. It's important the dump file not fit in RAM.) $ time pg_restore -f /dev/null -t zedtable bench10000.dump real 1m12.646s user 0m0.355s sys 0m5.083s This compares rather favorably to "cat": $ time cat bench10000.dump >/dev/null real 3m6.627s user 0m0.167s sys 0m30.999s I then applied your patch and repeated the restore run: $ time pg_restore -f /dev/null -t zedtable bench10000.dump real 2m39.138s user 0m0.386s sys 0m28.493s So for me, the proposed patch actually makes it 2X slower. Watching it with "iostat 1", I'm seeing about 40MB/s disk read rate with HEAD, and 500MB/s with the patch; "cat" also shows read rate around 500MB/s. So yeah, we can saturate the disk interface by doing all reads and no seeks, but that doesn't net out faster. I did this on a few-years-old Dell Precision 5820 workstation. The specs for it are a bit vague about the disk subsystem: Storage Drive Controllers Integrated Intel AHCI SATA chipset controller (8x 6.0Gb/s), SW RAID 0,1,= 5,10 Storage Drive 2.5 1.92TB SATA AG Enterprise Solid State Drive and hdparm isn't enormously helpful either: ATA device, with non-removable media Model Number: SSDSC2KB019T8R = Serial Number: PHYF1291017A1P9DGN = Firmware Revision: XCV1DL69 Media Serial Num: = Media Manufacturer: = Transport: Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA= Rev 2.5, SATA Rev 2.6, SATA Rev 3.0 Standards: Used: unknown (minor revision code 0x006d) = Supported: 10 9 8 7 6 5 = Likely used: 10 I'm running RHEL 8.10, file system is xfs. So I find this a bit discouraging. It's not clear why you're seeing a win and I'm not, and it's even less clear whether there'd be enough of a win across enough platforms to make it worth trying to engineer a solution that helps many more people than it hurts. regards, tom lane