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 1ur1ud-00H5U8-UX for pgsql-general@arkaria.postgresql.org; Tue, 26 Aug 2025 22:13:09 +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 1ur1uc-00AoMt-Uf for pgsql-general@arkaria.postgresql.org; Tue, 26 Aug 2025 22:13:07 +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.94.2) (envelope-from ) id 1ur1uc-00AoMl-Jf for pgsql-general@lists.postgresql.org; Tue, 26 Aug 2025 22:13:07 +0000 Received: from mail-oo1-xc2b.google.com ([2607:f8b0:4864:20::c2b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ur1ua-001ueS-1z for pgsql-general@lists.postgresql.org; Tue, 26 Aug 2025 22:13:06 +0000 Received: by mail-oo1-xc2b.google.com with SMTP id 006d021491bc7-61ddf57921eso333441eaf.3 for ; Tue, 26 Aug 2025 15:13:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756246384; x=1756851184; darn=lists.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=15UdpdD3VTjpTCMCIi7o57qEu1mL/JSu7ZoG3QZQPgQ=; b=R/QoEwc09c5oojh84iWwifNNUE9LN/RUp+K8czxVOf1iHrkrar/qTOnXJpYXj6HA6S 8yfkYCv3lzlG2QPGvvpiWjJZXQcJwNvmTPBVUvzltowukZrycF+nUsaxq8EwDSVV4D9k sqMW3srsAgfmeMCGe4E0WxeyocyJFmvVkHsmFCVsCtNKqCpQx09FO+gaS/RU49X2nLxE c+sqC+WnZSErKs5YYm6wL163n4+8dopkGixK1IgOTFgVuowVUc+y1QplrHYvpZj4VIV0 oKMUw8GexXTKAFwH7lkIZGAf/NB0VcR7J4zXJn/cK10WyewDJrYs39YCsdbf+VLsWONl dHNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756246384; x=1756851184; 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=15UdpdD3VTjpTCMCIi7o57qEu1mL/JSu7ZoG3QZQPgQ=; b=rlsle7bT7MS1FWQG6U4QT3bSn+MQVwwsM/ha44/L7RzEsyl/R0NoFGmlyuu2HG/s8E iQ5bB0ulp6MrZPBm/2cLK7lPkx/BTpuGvyuFfvI144G+HtAFuqNHvQumPY6UXCtn4xes /2JXoPaSACWaYC2+7uSv0rgBTswA2Z0GLfGzhZ9+K3e8Z6z622TC7kW9ETe7AinOYT/f y1Ia5Y+YKSw++phKl9C2lB6ZSd1901eBmx8M3qdIaQSI7lOUJoudNde8GxHiFiSNLfjD KCq9q1Ufw1QkZx/2rNX31JdVbMeyhzE5QLEhq5d/gsKqC3++IcEQY5I2IxbECPt6fiq8 Jtrw== X-Gm-Message-State: AOJu0YyDfBZ3gyKgBhrL4Jjb4ML/+9S2ncJwsl75WgEUnFD3Plxro5g9 lGXC8cr4UlJhVIdcEgrmT7jPez8bsiIL8MOSpaQ20qiQesAUdkBkjamRlmSV42rWJz1c4GQavMm VfV7LWoLSjQJm73f7V27ddGKX7SKGdjF0dw== X-Gm-Gg: ASbGncu7BKIGPFoPpFYJm+edem8btDZiTOYRVRV9XvOSVDJSjpX/oKkImno5pchjrHF fsf76bxAWY+HDdPUPX58ueBH/cg0A6rkQVoCkMKOQ1hpvm8VPSybJ705/46rD2XtMPj7fa64oOi 5eoEB0W4a5Fs6OmGV0H8q2TJy1pySi99RM5ENkMuOWMTxbhMcGhVoDub9+xMW/MvkPEt47uEuDa BRCO2sH X-Google-Smtp-Source: AGHT+IH4a4u8ZM4GJiNnOoQ8q/YIIJ68TdJjT4IB9wZMZEWCAO6SCNlNZtsNpla72YC0nwV9+2MKxh09g/Ml0w6quVQ= X-Received: by 2002:a05:6808:a611:20b0:437:9427:125f with SMTP id 5614622812f47-43794271be0mr5351649b6e.14.1756246384493; Tue, 26 Aug 2025 15:13:04 -0700 (PDT) MIME-Version: 1.0 References: <1273426.1756246099@sss.pgh.pa.us> In-Reply-To: <1273426.1756246099@sss.pgh.pa.us> From: Ron Johnson Date: Tue, 26 Aug 2025 18:12:52 -0400 X-Gm-Features: Ac12FXwgwsdyPRErF6Zt_mK3ykcw7vPFLwBnQmaq4f7ZLkuVae8kZvx_bwyH244 Message-ID: Subject: Re: In-order pg_dump (or in-order COPY TO) To: "pgsql-generallists.postgresql.org" Content-Type: multipart/alternative; boundary="000000000000e2c7b3063d4bf9de" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000e2c7b3063d4bf9de Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Aug 26, 2025 at 6:08=E2=80=AFPM Tom Lane wrote: > Dimitrios Apostolou writes: > > Unfortunately after I did pg_restore to a new server, I notice that the > > dumps from the new server are not being de-duplicated, all blocks are > > considered new. > > > This means that the data has been significantly altered. The new dumps > > contain the same rows but probably in very different order. Could the > > row-order have changed when doing COPY FROM with pg_restore? > > I'd expect pg_dump/pg_restore to preserve the physical row ordering, > simply because it doesn't do anything that would change that. > > However, restoring into an empty table would result in a table with > minimal free space, whereas the original table probably had a > meaningful amount of free space thanks to updates and deletes. Thus > for example TIDs would not be the same. If your "rolling checksum" > methodology is at all sensitive to page boundaries, the table would > look quite different to it. > But the rolling checksums are against a pg_dump file, not a pg_basebackup file. What probably changed are table OIDs. Would that change the ordering of COPY data in post-restore dump files? --=20 Death to , and butter sauce. Don't boil me, I'm still alive. lobster! --000000000000e2c7b3063d4bf9de Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, Aug 26, 2025 at 6:08=E2=80=AFPM T= om Lane <tgl@sss.pgh.pa.us> = wrote:
Dimitrios Apostolou <jimis@gmx.net> writes:
> Unfortunately after I did pg_restore to a new server, I notice that th= e
> dumps from the new server are not being de-duplicated, all blocks are<= br> > considered new.

> This means that the data has been significantly altered. The new dumps=
> contain the same rows but probably in very different order. Could the =
> row-order have changed when doing COPY FROM with pg_restore?

I'd expect pg_dump/pg_restore to preserve the physical row ordering, simply because it doesn't do anything that would change that.

However, restoring into an empty table would result in a table with
minimal free space, whereas the original table probably had a
meaningful amount of free space thanks to updates and deletes.=C2=A0 Thus for example TIDs would not be the same.=C2=A0 If your "rolling checksu= m"
methodology is at all sensitive to page boundaries, the table would
look quite different to it.
=C2=A0
But= the rolling checksums are against a pg_dump file, not a pg_basebackup file= .

What probably changed are table OIDs.=C2=A0 Woul= d that change the ordering of COPY data in post-restore dump files?

--
Death to <Redacted&g= t;, and butter sauce.
Don't boil me, I'm still alive.
<= div><Redacted> lobster!
--000000000000e2c7b3063d4bf9de--