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 1vRT5U-00DriO-2C for pgsql-performance@arkaria.postgresql.org; Fri, 05 Dec 2025 10:30:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vRT5S-007a7o-2B for pgsql-performance@arkaria.postgresql.org; Fri, 05 Dec 2025 10:30:55 +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.96) (envelope-from ) id 1vRT5S-007a7g-19 for pgsql-performance@lists.postgresql.org; Fri, 05 Dec 2025 10:30:54 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vRT5P-003G6P-36 for pgsql-performance@lists.postgresql.org; Fri, 05 Dec 2025 10:30:53 +0000 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-6418738efa0so3425740a12.1 for ; Fri, 05 Dec 2025 02:30:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764930651; x=1765535451; darn=lists.postgresql.org; h=content-transfer-encoding:to:subject:message-id:date:from :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=0BJQI+OyXpQD3ZxeYlYYx75ifgKvY4o5hgCqf2IaINY=; b=Xc2N0Wvq4gvy9tueGrGIi8h+Ar1IB69NG80jqUyVRrMpB23Cf+QtA2MM+zMGpaCZ6P cRoE+GuBA0NhhdIBvJh31nukegj3xDnaHJSIZgs703ggpdujf323IjMZmGsR8ky2xh0Q 1yNaN4kfjSDfV7deQ7csmD3TPK6kU69+2KPg0Odbkj1xk4p/YZ0TCkIT7Rlg04NUulOE yq7nKmtlkApJqHtrtgKYJwGadmr8o6AV1paqn8u0WhgW69cuoYmWYmNWdWnu81aiNNW0 cpn6jq8fylqebBalcNSmnaSDDefI6/qlQVL6w8NvWIwJ+BJc77sGkvVibcVQBmjJRzOO W1ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764930651; x=1765535451; h=content-transfer-encoding:to:subject:message-id:date:from :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0BJQI+OyXpQD3ZxeYlYYx75ifgKvY4o5hgCqf2IaINY=; b=DrwN9gdXLCDHYYVCj98PZpVXOpA324Od/p+oYm+EWEDBJvWKJqBbTNprZ7myllbIVe I63XvB/g2hoM0KbIAI3JQ2Yy9+k9pez11uJnjxaR+uMRe2V3MwIM0Fe1AEkMpIfeLLS6 LbSvtojt/g2nLMNjuzG1FJAI9y6ai6DmtCiL2FvxNFdejCycTuJmJzMWHgpxeQdCmeAF 5zWh36oOXYHGDCkIu07E5nimi9TzqWnwqjfARjoY3dAwtyN1TZ9Delk3LWSBzbAKwbTO gteQVBrQXhvtikFUY3XuGUCMAqo0rpd7LoECw1P7rDVUik2X+uXOcZSr05/SZFCD631X 7sVQ== X-Gm-Message-State: AOJu0YwJcfhvJY6+Masz0Qe3IuF/DRmiLHtu6T0aIeQPMtMHj6WQiRKb gbjUOolvozLQWqob2NsiTifP7uIgnJHTpLMKlOHEhz5T5nauHik0fIfaxiiPG20fr3ixVMAuMBd 4etCgmrvHeH/Y9RIPNjygBdH4mzE5482pu5s1 X-Gm-Gg: ASbGncur/ljzyS7KMxowaonmIxtDz3X5l7v39cRNQ4s+qRL0n/0vgxStMYU5L2U66Oo MUQIYWpg7IykW2bByXyjMHcllVJkgrfqpzVPkU+UoBZN5SDQXAs6B60BiRPzL3WSJqq1yWKeQJc GXDCfWpLpklxgMxUmLQm1O0AsiNlMm8V9z7FwBauLxQCDSG6N7E6mVJuL+RtLHV+Nk7BpF7zJZS cvW9OsiT8JgL6FFC43wEUqjWgcaSOgMxlYEf3oNz19jY8LJiI8rWyiL0gdXexBIGWEefsYj X-Google-Smtp-Source: AGHT+IFrJucdguG2twZ4i1STuO2cQbVRhyONmgxhZSrxIC4VfFKqeTfYFRE3j7gQAf98p1FyygsUCkdTt55+HDFxPWY= X-Received: by 2002:a05:6402:35cd:b0:641:72a8:c921 with SMTP id 4fb4d7f45d1cf-6479c504208mr7774030a12.23.1764930649679; Fri, 05 Dec 2025 02:30:49 -0800 (PST) MIME-Version: 1.0 From: MentionTheElephant Date: Fri, 5 Dec 2025 11:30:38 +0100 X-Gm-Features: AQt7F2rJAhODBVLRv_s7nrE9_xUxhyh_hmKC6Uq4n84KWyGzG0uz2kkyTKZ4Cg8 Message-ID: Subject: Seeking guidance on extremely slow pg_restore despite strong I/O performance To: 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 Hello, I would greatly appreciate your insight into an issue where pg_restore runs significantly slower than expected, even though the underlying storage shows very high random write throughput. I am trying to understand which PostgreSQL mechanisms or system layers I should investigate next in order to pinpoint the bottleneck and improve restore performance. The central question is: What should I examine further to understand why checkpoint processing becomes the dominant bottleneck during restore, despite fsync=3Doff, synchronous_commit=3Doff, and excellent random write latency? Below is a detailed description of the environment, the behavior observed, the steps I have already taken, and the research performed so far. During pg_restore, execution time remains extremely long: around 2+ hours using a custom-format dump and over 4 hours using directory format. The machine consistently demonstrates high random write performance (median latency ~5 ms, ~45k random write IOPS), yet PostgreSQL logs show very long checkpoints where the write phase dominates (hundreds to thousands of seconds). Checkpoints appear to stall the entire restore process. I have tested multiple combinations of dump formats (custom and directory) and parallel jobs (j =3D 1, 12, 18). The restore duration barely changes. This strongly suggests that the bottleneck is not client-side parallelism but internal server behavior=E2=80=94specifically t= he checkpoint write phase. Example log excerpts show checkpoint write times consistently in the range of 600=E2=80=931100 seconds, with large numbers of buffers written (f= rom hundreds of thousands to over 1.6 million). Sync times remain negligible because fsync is disabled, reinforcing the suspicion that PostgreSQL's internal buffer flushing and write throttling mechanisms are the source of slowdown, not WAL or filesystem sync. Given that: * Storage is fast, * fsync and synchronous commits are disabled, * full_page_writes is off, * wal_level is minimal, * autovacuum is off, * the restore is the only workload, I am trying to determine what further PostgreSQL internals or Linux I/O mechanisms may explain why these checkpoints are taking orders of magnitude longer than the device=E2=80=99s raw write characteristics would suggest. I am particularly looking for guidance on: * Whether backend or checkpointer write throttling may still be limiting write concurrency even during bulk restore, * Whether XFS on Hyper-V VHDX + LVM + battery-backed SSD could introduce any serialization invisible to raw I/O tests, * Whether certain parameters (e.g., effective_io_concurrency, maintenance_io_concurrency, wal_writer settings, combine limits, io_uring behavior) could unintentionally reduce write throughput, * Whether parallel pg_restore is inherently constrained by global buffer flushing behavior, * Any other PostgreSQL mechanisms that could cause prolonged checkpoint write durations even with crash-safety disabled. Below are the configuration values and environment details referenced above= . Machine: Hyper-V VM 24 vCPU 80 GB RAM Ubuntu 24.04.3 (kernel 6.8.0-88) PostgreSQL 18.1 Database size: ~700 GB across two tablespaces on separate disks (freshly restored) Storage layout: Each disk is its own VHDX LVM on battery-backed SSD array XFS for PGDATA Barriers disabled Random write performance (steady state): Median latency: 5.1 ms IOPS: ~45.6k Restore tests: pg_restore custom format: ~2h+ pg_restore directory format: ~4h+ Parallelism tested with j =3D 1, 12, 18, 24 Representative checkpoint log entries: (write phases ranging 76=E2=80=931079 seconds, buffer writes up to 1.6M) postgresql.conf (relevant parts): shared_buffers =3D 20GB work_mem =3D 150MB maintenance_work_mem =3D 8GB effective_io_concurrency =3D 1 maintenance_io_concurrency =3D 1 io_max_combine_limit =3D 512kB io_combine_limit =3D 1024kB io_method =3D io_uring fsync =3D off synchronous_commit =3D off wal_sync_method =3D fdatasync full_page_writes =3D off wal_compression =3D lz4 checkpoint_timeout =3D 60min checkpoint_completion_target =3D 0.9 max_wal_size =3D 80GB min_wal_size =3D 10GB effective_cache_size =3D 65GB autovacuum =3D off max_locks_per_transaction =3D 256 If anyone has encountered similar behavior or can recommend specific PostgreSQL subsystems, kernel settings, or I/O patterns worth investigating, I would be very grateful for advice. My main goal is to understand why checkpoint writes are so slow relative to the hardware=E2=80=99s demonstrated capabilities, and how to safely accelerate = the restore workflow. Thank you in advance for any guidance.