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 1ur0Kf-00Gfan-6m for pgsql-general@arkaria.postgresql.org; Tue, 26 Aug 2025 20:31:54 +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 1ur0Ke-00A1XJ-Gp for pgsql-general@arkaria.postgresql.org; Tue, 26 Aug 2025 20:31:53 +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 1ur0Ke-00A1XA-6a for pgsql-general@lists.postgresql.org; Tue, 26 Aug 2025 20:31:52 +0000 Received: from mail-ot1-x332.google.com ([2607:f8b0:4864:20::332]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ur0Kc-0021JY-2i for pgsql-general@lists.postgresql.org; Tue, 26 Aug 2025 20:31:52 +0000 Received: by mail-ot1-x332.google.com with SMTP id 46e09a7af769-74381df387fso1621993a34.0 for ; Tue, 26 Aug 2025 13:31:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756240309; x=1756845109; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Swn5CSxv5ZZ197YehEYiBzlwzzeWL8niL+wut9Afc1k=; b=GAg3lof3+xhLSfyN0FCBf/hI7+ViGdxxuBbU8RTs8TyRdl6orP0PEOBOZo1Re5N5yG 0SIzIYYmpRqmek/+39xRFGac0HKPebquPDCXXj1jXSABqFgX9DrZ6NrhLEEBmHd9msFQ z1n6tD/sDL433jedbSMa9KEFdw37ou0/krPvQlcuoujco4BIfRCAEetOg9ddkL/OI6Fo 7PVaK4Q4mQCr6GN1hnNlBibn8K7O6cyWHL/8UzCI5PSVtnApyf2UDfCs3rSp5VoNsR5S hIC8Ma9/nhxRsZArmlPnnmXG3QbGgbTUYQtq61YvxdwOh7LJfj65lThUBGPKt77lcI8w GN/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756240309; x=1756845109; h=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=Swn5CSxv5ZZ197YehEYiBzlwzzeWL8niL+wut9Afc1k=; b=HlABdHFL6D2XMVQSvRqYFXguIEjHnqftSvUFMFx7NdUaxo3pjNwPGI6jd/FOm/O3st PbIPwEm3lvOCM8RDaPwD6ir0Zafn7DiBnoO9gwgSZN+0xTIOYvLhZliUrVzrU5YYVP0h RvpoDTZXgtTKoqnBi3FK+kaZd320BvijRQVBKP+ZmT4ceO1cBgSlnZJXrhbA0JJGKYIs ostuANYP2ZZFWAApPskNJ6b8JqejzmUbwiQMyqhSm7aLJq1Hf52sXcj53LXnfo0qRNOA ythlCYhD0ogFp0X84IGkHJXcjMIie2GcIop6Af14WGuIVNl1PyFsGgBnA3tNQJWuwNiD PuZg== X-Gm-Message-State: AOJu0Yx+KS/75wWK+Jgwv2w1QQb6B19eW+vFnd/TTmGeuhSlHZoUN73p axRz7duJMNv8dLVmk8Xlnn9C2QzXe1KtIBDIArWaqyCzffMMKuhPMj7CaKeSrP2iEUWunzvzZFJ n/nAR/P4rB0DS0e50w2O7HCFkVn1AFpc= X-Gm-Gg: ASbGncvrxHxn6EL4l80gpmmRWDyCDRAe2zkfrSORyXjs07ZWIQTK6wYug4zH5rdC4J7 t67hhyUhS6YmHK/x/cPmnV8eb2cYRvk425UZ0s/f3oEPI9A8a/H45195IBnkm2OB8bNZAHl4LmJ 4RtDMqSk45hvFoI9OooH4zQ121q7R2TCVKhKp77ArW7o2fygrAoFZcY9W0FV/Lx/9+L7b84tzoP JOEVeKdagh28IGqrQmvm/I3tQNUowfrB+1Unw== X-Google-Smtp-Source: AGHT+IHLQY4k6zU/toUB/g5haV/kAoTlKr/gxbw8QUF13kVwer8y7SeZNNMLii/Yn0fba3lWHhQ/YzBoX4ZwtRPr+yk= X-Received: by 2002:a05:6830:6501:b0:742:6d79:ed44 with SMTP id 46e09a7af769-74500af75f9mr10544772a34.28.1756240308848; Tue, 26 Aug 2025 13:31:48 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "David G. Johnston" Date: Tue, 26 Aug 2025 13:31:12 -0700 X-Gm-Features: Ac12FXwbZcnGLSd_Vw2mKWfWJksI6fX9HI-qdsTGFqmGMxh8mupYKpriJjNPqX4 Message-ID: Subject: Re: In-order pg_dump (or in-order COPY TO) To: Dimitrios Apostolou Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000bfcd69063d4a8f47" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000bfcd69063d4a8f47 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Aug 26, 2025 at 12:43=E2=80=AFPM Dimitrios Apostolou wrote: > Could the > row-order have changed when doing COPY FROM with pg_restore? There is no reliable, meaningful, row ordering when it comes to the physical files. Sure, cluster does make an attempt, but it is quite limited in practice. > A *logical* dump of data shouldn't be affected by on-disk order. > Internal representation shouldn't affect the output. > The logical dump has no ordering - it will come out however it comes out. "COPY TO ..." doesn't have an order by clause - there is no way to make or communicate to it that ordering is important. For adhoc work you can use "COPY TO ..." and put and order by in the query. David J. --000000000000bfcd69063d4a8f47 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, Aug 26, 2025 at 12:43=E2=80=AFPM Dimitrios Apostol= ou <jimis@gmx.net> wrote:= =C2=A0
<= /div>
Could the
row-order have changed when doing COPY FROM with pg_restore?

There is no reliable, meaningful, row ordering when it= comes to the physical files.=C2=A0 Sure, cluster does make an attempt, but= it is quite limited in practice.


A *logical* dump of data shouldn't be affected by on-disk order.
Internal representation shouldn't affect the output.

The logical dump has no ordering - it will come out however= it comes out.=C2=A0 "COPY <table> TO ..." doesn't have= an order by clause - there is no way to make or communicate to it that ord= ering is important.=C2=A0 For adhoc work you can use "COPY <query&g= t; TO ..." and put and order by in the query.

Dav= id J.

--000000000000bfcd69063d4a8f47--