Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 3AE102E0030 for ; Thu, 5 Jun 2008 03:20:32 -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 55109-04 for ; Thu, 5 Jun 2008 03:20:21 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from outmail137154.authsmtp.co.uk (outmail137154.authsmtp.co.uk [62.13.137.154]) by developer.postgresql.org (Postfix) with ESMTP id 506762E002C for ; Thu, 5 Jun 2008 03:20:21 -0300 (ADT) Received: from mail-c188.authsmtp.com (mail-c188.authsmtp.com [62.13.128.25]) by punt6.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id m556KK6A081567 for ; Thu, 5 Jun 2008 07:20:20 +0100 (BST) Received: from [192.168.0.3] (85-211-65-92.dyn.gotadsl.co.uk [85.211.65.92]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id m556KJDL097658 for ; Thu, 5 Jun 2008 07:20:19 +0100 (BST) Subject: pg_dump restore time and Foreign Keys From: Simon Riggs To: pgsql-hackers Content-Type: text/plain Date: Thu, 05 Jun 2008 07:23:23 +0100 Message-Id: <1212647003.19964.19.camel@ebony.site> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 Content-Transfer-Encoding: 7bit X-Server-Quench: 78fa85a4-32c7-11dd-aecc-001871e930f4 X-AuthRoute: OCdxZQATClZOTQEd DAteCiNZVAwpPBRK HVkIKg5MOFUSTAAU Mk9RLVdJK3UEQkpF VCReGBUITgIzDi11 bhUrKFtCYEpOVxVq V0JLQlhQFEtgBAID Bx8AVBxsfgdZenty YFliEC1eWUIBDzIB QkdTE2gOK2ZjYWVR V0gOJgtRIQdXfR0W bU1+VSdZfDRSNSl9 R1dqb29oMGQEcCoJ VBkCGl4PRF5DBDMn WxcYEH0zHEgIDyw1 I1QILUQRHUkXemY/ IEBJ X-Authentic-SMTP: 61633235383639.cat.dmpriest.net.uk:1045/Kp X-Report-SPAM: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-Virus-Status: No virus detected - but ensure you scan with your own anti-virus system! X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200806/216 X-Sequence-Number: 119329 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. :-) -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support