Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 1FB862E0044 for ; Sat, 7 Jun 2008 14:08:17 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 07042-07 for ; Sat, 7 Jun 2008 14:08:13 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from vms046pub.verizon.net (vms046pub.verizon.net [206.46.252.46]) by developer.postgresql.org (Postfix) with ESMTP id 748042E003F for ; Sat, 7 Jun 2008 14:08:14 -0300 (ADT) Received: from ridley.home ([71.179.5.175]) by vms046.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0K23002SWRLDOYF6@vms046.mailsrvcs.net> for pgsql-hackers@postgresql.org; Sat, 07 Jun 2008 12:08:02 -0500 (CDT) Date: Sat, 07 Jun 2008 13:08:00 -0400 From: Robert Treat Subject: Re: pg_dump restore time and Foreign Keys In-reply-to: <1212670595.19964.55.camel@ebony.site> To: pgsql-hackers@postgresql.org Cc: Simon Riggs , Andrew Dunstan Message-id: <200806071308.00845.xzilla@users.sourceforge.net> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-15 Content-transfer-encoding: 7bit Content-disposition: inline References: <1212647003.19964.19.camel@ebony.site> <4847D4A7.70309@dunslane.net> <1212670595.19964.55.camel@ebony.site> User-Agent: KMail/1.9.9 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200806/340 X-Sequence-Number: 119453 On Thursday 05 June 2008 08:56:35 Simon Riggs wrote: > On Thu, 2008-06-05 at 07:57 -0400, Andrew Dunstan wrote: > > 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. > > OK, understood. Two negatives is enough to sink it. > Heh, I would have argued that the idea should go the other way and just make this part of the normal syntax. Oracle DBA's have been doing this for years (MS SQL supports it too actually) and it really helps working around having to hold locks on large relations for lengthy periods of times. Heck, I'd like to see a no check option for all constraints really. -- Robert Treat Build A Brighter LAMP :: Linux Apache {middleware} PostgreSQL