pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tore Halvorsen <tore.halvorsen@gmail.com>
Cc: Postgres General <pgsql-general@postgresql.org>
Subject: Re: pg_dump and pg_restore and foreign keys
Date: Wed, 27 Oct 2021 09:27:51 -0400
Message-ID: <237198.1635341271@sss.pgh.pa.us> (raw)
In-Reply-To: <CADGw-Sc7dKvR1j6efmXxUJc6ePWpfvKGACcfw30Pytv-7Da6JA@mail.gmail.com>
References: <CADGw-Sc7dKvR1j6efmXxUJc6ePWpfvKGACcfw30Pytv-7Da6JA@mail.gmail.com>

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





view thread (6+ messages)  latest in thread

Message-ID: <237198.1635341271@sss.pgh.pa.us>
Permalink:  ../237198.1635341271@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/237198.1635341271@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, tore.halvorsen@gmail.com
  Subject: Re: pg_dump and pg_restore and foreign keys
  In-Reply-To: <237198.1635341271@sss.pgh.pa.us>
  References: <CADGw-Sc7dKvR1j6efmXxUJc6ePWpfvKGACcfw30Pytv-7Da6JA@mail.gmail.com> <237198.1635341271@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox