Re: pg_dump and pg_restore and foreign keys

From: Tore Halvorsen <tore(dot)halvorsen(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: pg_dump and pg_restore and foreign keys
Date: 2021-10-27 13:50:23
Message-ID: CADGw-Se5ZuSTfW5NXKpgJPkuiLNWskbb21oJG_gJpiK=prZa=A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

That would be appending it for "pg_catalog.pg_get_constraintdef(oid) AS
condef" in getConstraints in pg_dump.c?

On Wed, Oct 27, 2021 at 3:27 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Tore Halvorsen <tore(dot)halvorsen(at)gmail(dot)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
>

--
Eld på åren og sol på eng gjer mannen fegen og fjåg. [Jøtul]
<demo> Tore Halvorsen || +052 0553034554

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2021-10-27 14:04:26 Re: pg_dump and pg_restore and foreign keys
Previous Message Tom Lane 2021-10-27 13:27:51 Re: pg_dump and pg_restore and foreign keys