Re: pg_dump and pg_restore and foreign keys - Mailing list pgsql-general

From Tom Lane
Subject Re: pg_dump and pg_restore and foreign keys
Date
Msg-id 237198.1635341271@sss.pgh.pa.us
Whole thread Raw
In response to pg_dump and pg_restore and foreign keys  (Tore Halvorsen <tore.halvorsen@gmail.com>)
Responses Re: pg_dump and pg_restore and foreign keys
List pgsql-general
Tore Halvorsen <tore.halvorsen@gmail.com> writes:
> I'm trying to restore a database where adding foreign key constraints takes
> most of the time. Does there exist a simple way to make either pg_dump or
> pg_restore handle them as "not valid", and defer the validation.

No.  It's kind of a neat idea perhaps, but it's not there.  You could

* use parallel pg_restore to alleviate the pain, or

* use pg_restore's -l and -L switches to strip out the FKs altogether,
and then re-add them manually afterwards.

Or there's always

* hack the pg_dump source code to include NOT VALID.  While a real
feature patch that made this optional would be a bit complicated,
doing it unconditionally should be a one-line change.

            regards, tom lane



pgsql-general by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: Python3 for PostgreSQL 14
Next
From: Tore Halvorsen
Date:
Subject: Re: pg_dump and pg_restore and foreign keys