Re: pg_dump dependency / physical hot backup

From: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>
To: Rod Taylor <pg(at)rbt(dot)ca>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_dump dependency / physical hot backup
Date: 2003-11-23 12:39:24
Message-ID: 3FC0AA7C.4010108@pse-consulting.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Rod Taylor wrote:

>>There might be discussions whether its better to script
>>CREATE TABLE xxx ..;
>>ALTER TABLE xxx ADD PRIMARY KEY ....;
>>ALTER TABLE xxx ADD FOREIGN KEY ....;
>>or
>>CREATE TABLE xxx (...., PRIMARY KEY (..), FOREIGN KEY (..));
>>
>>I'd opt for the second version (a little formatted, maybe :-)
>>
>>
>
>Well.. the second one will be much slower when the foreign keys verify.
>
>
Verifying zero rows in the freshly created table should be quite fast...

>Primary, unique constraints I'll buy in the create statement. Check
>constraints and defaults are a little fuzzier.
>
>Logic will be required to pull them out in the event they call functions
>which depends on the table or we enable subqueries (assertion like
>constraints) in them.
>
>
>
Yes, complicated constructions might prevent creating a table's objects
in a single step. It's probably possible to design an object that can't
be extracted automatically and restored at all (e.g. a view using itself).

I wonder if there have been discussions about other ways to
backup/restore. The current pg_dump/pg_restore way will rebuild all
indexes etc, resulting in a fresh and consistent database after restore,
enabling backend upgrades, but it's tricky to guarantee everything runs
smoothly. And it can be quite slow. In a case of a disaster recovery,
this is probably very unlucky.
I wonder if a mixture of pg_dump and physical cluster backup(currently
only possible if backend is shut down) could be implemented, i.e. a
BACKUP sql command. This command should stream out all data from the
physical files, taking a snapshot. When restoring, the command would
create a new database from the input data, by more or less copying the
data to files. This way, all (hopefully non-existent) inconsistencies in
the database would be restored as well (probably including non-vacuumed
rows), but because no checks are applied the restore process would be as
fast as possible. This would be possible only for the same
backend/architecture version, but in case of disaster recovery that's
enough.

Regards,
Andreas

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nigel J. Andrews 2003-11-23 14:04:35 Re: Commercial binary support?
Previous Message Kurt Roeckx 2003-11-23 12:33:19 Re: [7.4] statistics collector: Protocol not supported