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 1u2llP-005gzP-Rm for pgsql-performance@arkaria.postgresql.org; Thu, 10 Apr 2025 06:51:51 +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 1u2lkO-009P3T-DX for pgsql-performance@arkaria.postgresql.org; Thu, 10 Apr 2025 06:50:48 +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 1u2lkO-009P3H-17 for pgsql-performance@lists.postgresql.org; Thu, 10 Apr 2025 06:50:48 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u2lkL-004TlS-2j for pgsql-performance@lists.postgresql.org; Thu, 10 Apr 2025 06:50:47 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-43d5f10e1aaso42525e9.0 for ; Wed, 09 Apr 2025 23:50:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1744267845; x=1744872645; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=LDSRC2GPXLq29CwdBqlXNtDoehKqSDPBEc1wDy6Wu14=; b=P23OCyE4SIJzOqR01GeV2VrpJSFWHYZRXHY7eiVWGwxZzqt/B6mF9DMOe+SwJNCPyg W64D/W+Cc10vvmp6xUTPx6I2jRkTKsHwjRRHM/A6+zsQWx6807fMNvd6qfO3nIvmhZmY XZdxAvyifLg5IYPaU5C0+80VT/JgsbXy4QAfGTUqCSfugjoUqDkSCqysmpiLthGzFVmf QwPMcAx0SdP7Z/p+0YYLugeNObYf4mPc/DTvyOZFWwAU9opQoZiV+nGJzzZomZP1RXXJ rLju14Vrtz7wV+ShadNG8+C6sF+Ik2/e6rY14ZC6I50AVJIlN6uNvLjhXERFYLH110uL cIuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744267845; x=1744872645; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LDSRC2GPXLq29CwdBqlXNtDoehKqSDPBEc1wDy6Wu14=; b=EjkHoch+cwdZ0fi912mDfxhtLYw2ojy8IGlaBQv0Mxm4+0FW2yQ7QJGMrnAlM6Dc7S 5FCeSeDva3j/cuvLIszssrSOOvjyoDtAv2BD+2Cw1ywPuOGivETFFk3HavbTYFB2kx45 HydwCFgAWM4Zf7BsVcv+3/D0CPGO2/NdhEP2l/KJWcQTZsIGYLKgtgmcZ0Go6A0fmPff D7dqEeGKUTMHdANhjorXbn793bvU+QUtBW5IqEnbQSFTGIt39hI/WPuvCTRBKO75BpX3 VOqh01j7J1zyUGuuB2DIW9Esul+MQ+NUlnrJaTNFiLlwwN4vGGbyrGZAfg1214YtE6JN BUeA== X-Gm-Message-State: AOJu0YyMJT7CzXjOkU2IDRpkbvxcL0BgwZ2hpWb+kNHK9QYVchao29Cj jrXu2BvIKed0rYEyNJt+7Cj3qoQFk8z63D/K6+XUtyukiCrG037LhnbxQRZ0dMRyo+pyGfJcqyv kYr2BbFlVNf4amALjIE+xWWcwdPg+FeYH1OX/GZj+1SxiarnsBFu+ X-Gm-Gg: ASbGnctPZEXhWqrEmGVxqI4/Rusyea633lS8gpPSNM6JDv3k1/pQYWc7sgogesj1ZZF orz5RkiMwU0OcfX+lczdx+0jKTD3r1KL/gW3RiBjJISDOGTY+yzZTD0gJm134SP7fyxO7O4q2zP 2HW0Hu4V00nIZBEL92A/K6Mw== X-Google-Smtp-Source: AGHT+IG37epmYtVRguJHGkwPm/vQlKDNKL7GBVvfR6ZwllhpLhkhL0TwXz74sltpgFzOiJg0hcOi9rlVTTBtX4PcZrg= X-Received: by 2002:a05:600c:1f8c:b0:43b:b106:bb1c with SMTP id 5b1f17b1804b1-43f2dace339mr741855e9.0.1744267844461; Wed, 09 Apr 2025 23:50:44 -0700 (PDT) MIME-Version: 1.0 References: <6bd16bdb-aa5e-0512-739d-b84100596035@gmx.net> <1095774.1742498237@sss.pgh.pa.us> <556498.1742744802@sss.pgh.pa.us> In-Reply-To: <556498.1742744802@sss.pgh.pa.us> From: Hannu Krosing Date: Thu, 10 Apr 2025 08:50:33 +0200 X-Gm-Features: ATxdqUG6YPIIECgHpGs5hnjsvNxbxBN4M_BD7tAwFIfwtRn_AkV5THK2q3pwmSI Message-ID: Subject: Re: parallel pg_restore blocks on heavy random read I/O on all children processes To: Dimitrios Apostolou , Tom Lane Cc: pgsql-performance@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk You may be interested in a patch "Adding pg_dump flag for parallel export to pipes"[1] which allows using pipes in directory former parallel dump and restore. There the offsets are implicitly taken care of by the file system. [1] https://www.postgresql.org/message-id/CAH5HC97p4kkpikar%2BswuC0Lx4YTVkE= 30sTsFX94tyzih7Cc_%3Dw%40mail.gmail.com On Sun, Mar 23, 2025 at 4:46=E2=80=AFPM 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: > > > * Does the same happen in an uncompressed dump? Or maybe the offsets ar= e > > pre-filled because they are predictable without compression? > > Yes; no. We don't know the size of a table's data as-dumped until > we've dumped it. > > > * Should pg_dump print some warning for generating a lower quality form= at? > > I don't think so. In many use-cases this is irrelevant and the > warning would just be an annoyance. > > > * 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. > > > * Why doesn't it happen in single-process pg_restore? > > A single-process restore is going to restore all the data in the order > it appears in the archive file, so no seeking is required. Of course, > as soon as you ask for parallelism, that doesn't work too well. > > Hypothetically, maybe the algorithm for handing out tables-to-restore > to parallel workers could pay attention to the distance to the data > ... except that in the problematic case we don't have that > information. I don't recall for sure, but I think that the order of > the TOC entries is not necessarily a usable proxy for the order of the > data entries. It's unclear to me that overriding the existing > heuristic (biggest tables first, I think) would be a win anyway. > > regards, tom lane > >