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.96) (envelope-from ) id 1vJdsD-00EJg0-36 for pgsql-hackers@arkaria.postgresql.org; Thu, 13 Nov 2025 20:24:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vJdsA-003EBV-1O for pgsql-hackers@arkaria.postgresql.org; Thu, 13 Nov 2025 20:24:50 +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.96) (envelope-from ) id 1vJdsA-003EBF-05 for pgsql-hackers@lists.postgresql.org; Thu, 13 Nov 2025 20:24:50 +0000 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vJds6-007bAb-1D for pgsql-hackers@lists.postgresql.org; Thu, 13 Nov 2025 20:24:48 +0000 Received: by mail-qt1-x834.google.com with SMTP id d75a77b69052e-4ed67a143c5so60711cf.0 for ; Thu, 13 Nov 2025 12:24:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1763065485; x=1763670285; 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=7Wp9rwaX98Xbq4sBBxW/FIo/rvFFYVTYe9yLCdBN3AE=; b=p5wfzG1NStM7HDEXLm/nCe0LpkYLXIfTkFBHSOMjkUFEs6gGxBwVhQyV+qUTQdI3pZ fqpq2RPu4p/l1JsqpTdYOK8zrmgI4knlJxWg+pU5K6/7Fi6vp2YSIA9NlJvTJPvxXdsz W3mAfkO7vaNeibkhgLN8IrqTkEsceX1Ccrj4sZXWIZpiO81xf/tVK3Wwki3Cki7eOEsr AOGD3gGr2peY+vySFF02qTC6epCVg9MNWNEQXFoocYYCDEWZcqI+d8udabjA4hBpD06t RD5qStkJ0jnM8+g0K71hx2gcbF9LEfZkeMv8v+zaoRQmiNm7EFXFhBS1JQK0dJJPa6Nr /6ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763065485; x=1763670285; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=7Wp9rwaX98Xbq4sBBxW/FIo/rvFFYVTYe9yLCdBN3AE=; b=Ht1fC486nSuN7ZlNVEYzYaJdOpPT67JzjXtqxe4sNZBRWSUTRsuocq6oJQbmGsg8Qy da2797m9FeGxIv93FZbP9KuyMDzsFh6/10DDgCdBYrtyvd7DV59sHhKaAynULTyRf6qe ZfKV/q6y9JUCXUDrztlphmhhrar9rP1UYdI011x/zmYbhQ+vW7e8qBU7nDljl55HC5ci yybRb3c8tBDoXNa3PXis/Sg+ZEPqN5WWDS6qbK1vT9RaynXLVuSnWMskWcvlKs7qZeAP JZ6S+QhnYNpy3mjsP9cnOLpQ5KL/XslLOyKqkVZQXONH5X0//kL+QXH7l0DdiXQCxOk4 UoTg== X-Gm-Message-State: AOJu0YxxMlAYCMOKA4gyMLOsb9eB0L9SZ9UhDficAHiWh+FMbxC593IG MKK5slPq5QuLcCICweNkesf8cUkotjVlAb5hJ4UCiJmMWNywxif4oHz85ViWtik2LlliKS0XimH DkxqmHVLV6Pc182GzNUGaYY1O1S4k0qACf/ca7fHQ X-Gm-Gg: ASbGnctqwyT0ThF+DjuYja079t0e6+PFr9gs3+751l8t7r016jah9Cjau2Iu/RkB+gd GFYs1rRgSzWogC6jvpNcf6YAUOnrCOd5El8meVrRvZGJRsxtr1cEj4cAYF52r1Quo/PiRmXGDwR mIjIDfDRVdcK+wtRKAI2t1Pf/g+/5TWMDXii6HcwFFHfoPZdFk3t/cH/x/04DX9Hnakp5aOvlK1 bhKqYhvWWB4sF5ISqlUe4MqtYMc4GJdwP6pV1PDLYsODfHRb359iUgQTgQN0Mxi6fYmNJpJ5cd8 5n3t X-Google-Smtp-Source: AGHT+IHnGMy1PZecHkM7lTb7CqYyWQ/Sk5OsnN0KZ+LBTNXTlHwykkItfyJucfL5TJA3HjvSF49dkB3WYvpFjoZ7hCQ= X-Received: by 2002:a05:622a:1193:b0:4e4:f2b9:55aa with SMTP id d75a77b69052e-4edf33a5135mr826391cf.17.1763065484440; Thu, 13 Nov 2025 12:24:44 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Hannu Krosing Date: Thu, 13 Nov 2025 21:24:33 +0100 X-Gm-Features: AWmQ_bmNEjMmmMAI_4pwZ9M9JDSUho5MASRFHOGpnW-BZLZCVFziXHLb7BXL3Sg Message-ID: Subject: Re: Patch: dumping tables data in multiple chunks in pg_dump To: Ashutosh Bapat Cc: PostgreSQL Hackers , Nathan Bossart 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 Ran another test with a 53GB database where most of the data is in TOAST CREATE TABLE just_toasted( id serial primary key, toasted1 char(2200) STORAGE EXTERNAL, toasted2 char(2200) STORAGE EXTERNAL, toasted3 char(2200) STORAGE EXTERNAL, toasted4 char(2200) STORAGE EXTERNAL ); and the toast fields were added in somewhat randomised order. Here the results are as follows Parallelism | chunk size (pages) | time (sec) 1 | - | 240 2 | 1000 | 129 4 | 1000 | 64 8 | 1000 | 36 16 | 1000 | 30 4 | 9095 | 78 8 | 9095 | 42 16 | 9095 | 42 The reason larger chunk sizes performed worse was that they often had one or two stragglers left behind which Detailed run results below: hannuk@pgn2:~/work/postgres/src/bin/pg_dump$ time ./pg_dump --format=3Ddirectory -h 10.58.80.2 -U postgres -f /tmp/ltoastdb-1-plain.dump largetoastdb real 3m59.465s user 3m43.304s sys 0m15.844s hannuk@pgn2:~/work/postgres/src/bin/pg_dump$ time ./pg_dump --format=3Ddirectory -h 10.58.80.2 -U postgres --huge-table-chunk-pages=3D9095 -j 4 -f /tmp/ltoastdb-4.dump largetoastdb real 1m18.320s user 3m49.236s sys 0m19.422s hannuk@pgn2:~/work/postgres/src/bin/pg_dump$ time ./pg_dump --format=3Ddirectory -h 10.58.80.2 -U postgres --huge-table-chunk-pages=3D9095 -j 8 -f /tmp/ltoastdb-8.dump largetoastdb real 0m42.028s user 3m55.299s sys 0m24.657s hannuk@pgn2:~/work/postgres/src/bin/pg_dump$ time ./pg_dump --format=3Ddirectory -h 10.58.80.2 -U postgres --huge-table-chunk-pages=3D9095 -j 16 -f /tmp/ltoastdb-16.dump largetoastdb real 0m42.575s user 4m11.011s sys 0m26.110s hannuk@pgn2:~/work/postgres/src/bin/pg_dump$ time ./pg_dump --format=3Ddirectory -h 10.58.80.2 -U postgres --huge-table-chunk-pages=3D1000 -j 16 -f /tmp/ltoastdb-16-1kpages.dump largetoastdb real 0m29.641s user 6m16.321s sys 0m49.345s hannuk@pgn2:~/work/postgres/src/bin/pg_dump$ time ./pg_dump --format=3Ddirectory -h 10.58.80.2 -U postgres --huge-table-chunk-pages=3D1000 -j 8 -f /tmp/ltoastdb-8-1kpages.dump largetoastdb real 0m35.685s user 3m58.528s sys 0m26.729s hannuk@pgn2:~/work/postgres/src/bin/pg_dump$ time ./pg_dump --format=3Ddirectory -h 10.58.80.2 -U postgres --huge-table-chunk-pages=3D1000 -j 4 -f /tmp/ltoastdb-4-1kpages.dump largetoastdb real 1m3.737s user 3m50.251s sys 0m18.507s hannuk@pgn2:~/work/postgres/src/bin/pg_dump$ time ./pg_dump --format=3Ddirectory -h 10.58.80.2 -U postgres --huge-table-chunk-pages=3D1000 -j 2 -f /tmp/ltoastdb-2-1kpages.dump largetoastdb real 2m8.708s user 3m57.018s sys 0m18.499s On Thu, Nov 13, 2025 at 7:39=E2=80=AFPM Hannu Krosing w= rote: > > Going up to 16 workers did not improve performance , but this is > expected, as the disk behind the database can only do 4TB/hour of > reads, which is now the bottleneck. (408/352/*3600 =3D 4172 GB/h) > > $ time ./pg_dump --format=3Ddirectory -h 10.58.80.2 -U postgres > --huge-table-chunk-pages=3D131072 -j 16 -f /tmp/parallel16.dump largedb > real 5m44.900s > user 53m50.491s > sys 5m47.602s > > And 4 workers showed near-linear speedup from single worker > > hannuk@pgn2:~/work/postgres/src/bin/pg_dump$ time ./pg_dump > --format=3Ddirectory -h 10.58.80.2 -U postgres > --huge-table-chunk-pages=3D131072 -j 4 -f /tmp/parallel4.dump largedb > real 10m32.074s > user 38m54.436s > sys 2m58.216s > > The database runs on a 64vCPU VM with 128GB RAM, so most of the table > will be read in from the disk > > > > > > > On Thu, Nov 13, 2025 at 7:02=E2=80=AFPM Hannu Krosing = wrote: > > > > I just ran a test by generating a 408GB table and then dumping it both = ways > > > > $ time pg_dump --format=3Ddirectory -h 10.58.80.2 -U postgres -f > > /tmp/plain.dump largedb > > > > real 39m54.968s > > user 37m21.557s > > sys 2m32.422s > > > > $ time ./pg_dump --format=3Ddirectory -h 10.58.80.2 -U postgres > > --huge-table-chunk-pages=3D131072 -j 8 -f /tmp/parallel8.dump largedb > > > > real 5m52.965s > > user 40m27.284s > > sys 3m53.339s > > > > So parallel dump with 8 workers using 1GB (128k pages) chunks runs > > almost 7 times faster than the sequential dump. > > > > this was a table that had no TOAST part. I will run some more tests > > with TOASTed tables next and expect similar or better improvements. > > > > > > > > On Wed, Nov 12, 2025 at 1:59=E2=80=AFPM Ashutosh Bapat > > wrote: > > > > > > Hi Hannu, > > > > > > On Tue, Nov 11, 2025 at 9:00=E2=80=AFPM Hannu Krosing wrote: > > > > > > > > Attached is a patch that adds the ability to dump table data in mul= tiple chunks. > > > > > > > > Looking for feedback at this point: > > > > 1) what have I missed > > > > 2) should I implement something to avoid single-page chunks > > > > > > > > The flag --huge-table-chunk-pages which tells the directory format > > > > dump to dump tables where the main fork has more pages than this in > > > > multiple chunks of given number of pages, > > > > > > > > The main use case is speeding up parallel dumps in case of one or a > > > > small number of HUGE tables so parts of these can be dumped in > > > > parallel. > > > > > > Have you measured speed up? Can you please share the numbers? > > > > > > -- > > > Best Wishes, > > > Ashutosh Bapat