X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 09076D8A8C; Sat, 10 Sep 2005 11:42:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18140-05; Sat, 10 Sep 2005 14:42:13 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 5097CD78F2; Sat, 10 Sep 2005 10:06:27 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j8AD6S3g040369 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 10 Sep 2005 07:06:30 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j8AD6RGn045646; Sat, 10 Sep 2005 07:06:28 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j8AD6R8p045645; Sat, 10 Sep 2005 07:06:27 -0600 (MDT) (envelope-from mfuhr) Date: Sat, 10 Sep 2005 07:06:27 -0600 From: Michael Fuhr To: "Marc G. Fournier" Cc: pgsql-performance@postgresql.org Subject: Re: CHECK vs REFERENCES Message-ID: <20050910130627.GA45586@winnie.fuhr.org> References: <20050910001821.E1170@ganymede.hub.org> <20050910034907.GA40382@winnie.fuhr.org> <20050910010141.O1170@ganymede.hub.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050910010141.O1170@ganymede.hub.org> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] X-Spam-Level: X-Archive-Number: 200509/123 X-Sequence-Number: 14431 On Sat, Sep 10, 2005 at 01:03:03AM -0300, Marc G. Fournier wrote: > On Fri, 9 Sep 2005, Michael Fuhr wrote: > >INSERT INTO test_check SELECT 1 FROM generate_series(1, 100000); > >INSERT 0 100000 > >Time: 3492.344 ms > > > >INSERT INTO test_fk SELECT 1 FROM generate_series(1, 100000); > >INSERT 0 100000 > >Time: 23578.853 ms > > Yowch, I expected CHECK to be better ... but not so significantly ... I > figured I'd be saving milliseconds, which, on a busy server, would add up > fast ... but not 10k' of milliseconds ... Results will differ depending on the table structure: if you're indexing ten columns and have five triggers then the foreign key check will have less of an overall impact. -- Michael Fuhr