pg_dump order of rows

From: jan <jan(at)dafuer(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: pg_dump order of rows
Date: 2010-12-10 23:02:20
Message-ID: e023dbd5b1442c270a30c8c849b55aec@dafuer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hello,

today I stumbled across a interesting question about the order rows are dumped out while exporting a database with pg_dump. I know questions like this are around this list sometimes, but I think this is a bit more special.

First of all I know that dumping a database is a somewhat nondeterministic process. It's hard to determine in which order objects are dumped. If my understanding is correct when it's about dumping the rows from a specific table the rows will appear in the dump in disk-order. This order is changed everytime there are updates to rows in that table and how often a vacuum occurs to release old row versions.

From some testing I "verified" this by experimentation - just created a new table with a known order of rows and dumped it. The dump was ordered in the same way the rows were inserted. Same again with updating some of the rows those rows appeard at the end of the dump. At last I vacuumed the database and updated some rows they appeared in the "spaces" the previous updated rows left behind. Exactly what I expected :-)

Now for my question - we have a case where rows are inserted in order and are updated rarely (about 10% of the rows and often in order) and we are seeking for a solution to make the dumop (e.g. the backup) more random at database level (by influencing the on disk order)? Obvious way would be to update all rows randomly by software before dumpim

Responses

Browse pgsql-general by date

  From Date Subject
Next Message jan 2010-12-10 23:20:41 pg_dump order of rows
Previous Message Peter Eisentraut 2010-12-10 22:59:02 Re: Using regexp_replace to remove small words