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 1u0kAp-0073je-H8 for pgsql-general@arkaria.postgresql.org; Fri, 04 Apr 2025 16:45:43 +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 1u0kAn-002Saf-Sb for pgsql-general@arkaria.postgresql.org; Fri, 04 Apr 2025 16:45:41 +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 1u0kAn-002SaX-H5 for pgsql-general@lists.postgresql.org; Fri, 04 Apr 2025 16:45:41 +0000 Received: from mail-ot1-x330.google.com ([2607:f8b0:4864:20::330]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u0kAl-003OBY-0r for pgsql-general@postgresql.org; Fri, 04 Apr 2025 16:45:41 +0000 Received: by mail-ot1-x330.google.com with SMTP id 46e09a7af769-72c0cf1922bso318873a34.0 for ; Fri, 04 Apr 2025 09:45:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743785137; x=1744389937; darn=postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=83IGHfF1YBaKHx9Ipw57C6SOeT5KeWEJzVjPZX39coY=; b=B+KMJ2XTYWNorpRhgdDMh3DNI62py0Ab1BURuxDivu0knOcws/ISm1/5ra1A5bho9h MfmcjY3java3Ur19ldaf495A/FSjtdMxaL7gzB2cjpyloxz7GoeSC7L/oZfrG690saqa HhmcvIWlbG7PIXXmtvVOuFPu04Q/xONF6rKuru5VZQeT6snZ1LlxrqVq6fvoRJJRC94L XotPLuPyQ7jzGMde77C2r9j4e7B1HZGOXJLUha6qjOMR5rzDN7oHxaZwIJ1ZCJhHc1Pa o2UYkHvm04pbAk/KBPLN19NUr99ym0xhNqvGJb9dnizzFsf3NHppJUeLXcWrn0ZkpLxv GNAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743785137; x=1744389937; h=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=83IGHfF1YBaKHx9Ipw57C6SOeT5KeWEJzVjPZX39coY=; b=VOqghV6u1m4gnuJYaAwwj8Q5lmiiG60LbHB/gvGGxoE5r7ETGTLGIFOgsTyR2e43W9 s4HfL8ZNP8iFCvVrYtXXfPCq6ZfKJMmhL0t1t/niPuYc4i5w8Z9q59ZDq6mMmzWwwJMC lqBax2T5lySGrUoJoY9I73R5Hn2jf1BmGFww6vtYO+a57jWbUv+WIaR8gYUHahaberEx 7LckVyEnzobNRNlTyEWPDipvPTRH81vN8CXtBrK/y0c1RaqRvuUn/kUdU5wxBGF5nJFl UebG4NhaQCUgd6p7CzPYLWzTGX1FQcfOztiuwqKLb6vbv2ERnpBya/yaHeXSJUhrmK/M r8fw== X-Gm-Message-State: AOJu0Yx5hS26y6EaIBVyHyTtcgBXOHpmBcpKgx6xxdywE6MtO/S5Bfcw dDDmspldRxXmI01xUCSmVWJkhNsLfMHn4xaasXLmC01D7Gx9gi20Ze747y3pSBiVuhneQTqdGeE uNKa/oyzaH8TkwGV/8e8mu8/soN0ihw== X-Gm-Gg: ASbGncsofTQ2amQrBfOG8K1CdsSwjdcjo2in61S8DA8qPoqL4UuCc3a6cZBrogUeSzk KekeOELLTsB6v3G06d3q9lBWzrVLm96bMjpTemBue322XryXnZJhKpuOmY0JiUh/0mZmpMpLTex oiSIl/WYmkgR9X+oqH4Km1OQ+z0fUyHvZumAUDCkixONmaEogo+j5IyMedIQ5VuXsBqrA6Hg== X-Google-Smtp-Source: AGHT+IEIq0Tb/O15UcdXiDfamfzlJP/2HRsbsCfAKVtVU5zL0AZ3qkXWwceWoxsc8eMGrEooRaQ7YkCTPZ+rM3zvcBs= X-Received: by 2002:a05:6808:118a:b0:3f9:d5a2:89a6 with SMTP id 5614622812f47-4004563d596mr2231769b6e.35.1743785137288; Fri, 04 Apr 2025 09:45:37 -0700 (PDT) MIME-Version: 1.0 References: <84379bfb-bbda-84e6-cacc-e863ba9d6c37@gmx.net> In-Reply-To: <84379bfb-bbda-84e6-cacc-e863ba9d6c37@gmx.net> From: Ron Johnson Date: Fri, 4 Apr 2025 12:45:25 -0400 X-Gm-Features: ATxdqUEQoh51-EgJnEjreHAkcV07M9R-kGn7wx6jvEgHI-qeAzm_aUks_SEcAmg Message-ID: Subject: Re: Performance issues during pg_restore -j with big partitioned table To: pgsql-general Content-Type: multipart/alternative; boundary="000000000000ac3e6b0631f69de8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000ac3e6b0631f69de8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Apr 2, 2025 at 1:32=E2=80=AFPM Dimitrios Apostolou = wrote: > Hello list. > > My database includes one table with 1000 partitions, all of them rather > sizeable. I run: > > pg_restore -j12 --no-tablespaces --disable-triggers --exit-on-error > --no-owner --no-privileges -n public -d newdb custom_format_dump.pgdump > > Right now after 24h of restore, I notice weird behaviour, so I have > several questions about it: > > + 11 postgres backend processes are sleeping as "TRUNCATE TABLE waiting". > I see that they are waiting to issue a TRUNCATE for one of the > partitions and then COPY data to it. Checking the log I see that > several partitions have already been copied finished, but many more > are left to start. > > Why is a TRUNCATE needed at the start of a partition's COPY phase? I > didn't issue a --clean on the command line (I don't need it as my > database is newly created), and I don't see a mention of related > TRUNCATE in the pg_restore manual. > TRUNCATE statements inside of "toc.dat" files? I'm skeptical. Are you maybe doing something else in that database besides pg_restore? --=20 Death to , and butter sauce. Don't boil me, I'm still alive. lobster! --000000000000ac3e6b0631f69de8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, Apr 2, 2025 at 1:32=E2=80=AFPM Di= mitrios Apostolou <jimis@gmx.net>= ; wrote:
Hello list.

My database includes one table with 1000 partitions, all of them rather
sizeable. I run:

=C2=A0 =C2=A0pg_restore -j12 --no-tablespaces --disable-triggers --exit-on-= error --no-owner --no-privileges -n public -d newdb custom_format_dump.pgdu= mp

Right now after 24h of restore, I notice weird behaviour, so I have
several questions about it:

+ 11 postgres backend processes are sleeping as "TRUNCATE TABLE waitin= g".
=C2=A0 =C2=A0I see that they are waiting to issue a TRUNCATE for one of the=
=C2=A0 =C2=A0partitions and then COPY data to it.=C2=A0 Checking the log I = see that
=C2=A0 =C2=A0several partitions have already been copied finished, but many= more
=C2=A0 =C2=A0are left to start.

=C2=A0 =C2=A0Why is a TRUNCATE needed at the start of a partition's COP= Y phase? I
=C2=A0 =C2=A0didn't issue a --clean on the command line (I don't ne= ed it as my
=C2=A0 =C2=A0database is newly created), and I don't see a mention of r= elated
=C2=A0 =C2=A0TRUNCATE in the pg_restore manual.

TRUNCATE statements inside of "toc.dat"= files?=C2=A0 I'm skeptical.

Are you maybe doi= ng something else in that database besides pg_restore?

= --
Death to <Redacted>, and butter= sauce.
Don't boil me, I'm still alive.
<Redact= ed> lobster!
--000000000000ac3e6b0631f69de8--