Re: In-order pg_dump (or in-order COPY TO)

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Dimitrios Apostolou <jimis(at)gmx(dot)net>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: In-order pg_dump (or in-order COPY TO)
Date: 2025-08-26 20:31:12
Message-ID: CAKFQuwYBVFjoNFUzsomdvRQXEEQH5A4T-+_STE=WNUomw6LZSQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Aug 26, 2025 at 12:43 PM Dimitrios Apostolou <jimis(at)gmx(dot)net> 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 <table> 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 <query> TO ..." and put and order by in the query.

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2025-08-26 22:00:09 Re: In-order pg_dump (or in-order COPY TO)
Previous Message Laurenz Albe 2025-08-26 20:16:39 Re: How to configure client-side TLS ciphers for streaming replication?