pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Dunstan <andrew@dunslane.net>
To: Simon Riggs <simon@2ndquadrant.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: pg_dump restore time and Foreign Keys
Date: Thu, 05 Jun 2008 07:57:27 -0400
Message-ID: <4847D4A7.70309@dunslane.net> (raw)
In-Reply-To: <1212647003.19964.19.camel@ebony.site>
References: <1212647003.19964.19.camel@ebony.site>



Simon Riggs wrote:
> pg_dump restore times can be high when they include many ALTER TABLE ADD
> FORIEGN KEY statements, since each statement checks the data to see if
> it is fully valid in all cases.
>
> I've been asked "why we run that at all?", since if we dumped the tables
> together, we already know they match.
>
> If we had a way of pg_dump passing on the information that the test
> already passes, we would be able to skip the checks.
>
> Proposal:
>
> * Introduce a new mode for ALTER TABLE ADD FOREIGN KEY [WITHOUT CHECK];
> When we run WITHOUT CHECK, iff both the source and target table are
> newly created in this transaction, then we skip the check. If the check
> is skipped we mark the constraint as being unchecked, so we can tell
> later if this has been used.
>
> * Have pg_dump write the new syntax into its dumps, when both the source
> and target table are dumped in same run
>
> I'm guessing that the WITHOUT CHECK option would not be acceptable as an
> unprotected trap for our lazy and wicked users. :-)
>   

This whole proposal would be a major footgun which would definitely be 
abused, IMNSHO.

I think Heikki's idea of speeding up the check using a hash table of the 
foreign keys possibly has merit.

cheers

andrew



view thread (36+ messages)  latest in thread

Message-ID: <4847D4A7.70309@dunslane.net>
Permalink:  ../4847D4A7.70309@dunslane.net/
Also on:    postgresql.org/message-id/4847D4A7.70309@dunslane.net

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: andrew@dunslane.net, simon@2ndquadrant.com
  Subject: Re: pg_dump restore time and Foreign Keys
  In-Reply-To: <4847D4A7.70309@dunslane.net>

* 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