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 81700DB330 for ; Sat, 29 Oct 2005 15:02:13 -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 27622-07 for ; Sat, 29 Oct 2005 18:02:11 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id DE598DB32E for ; Sat, 29 Oct 2005 15:02:11 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j9TI1wJq011905; Sat, 29 Oct 2005 14:01:58 -0400 (EDT) To: Michael Fuhr Cc: Bruno Wolff III , Martin Lesser , Stephan Szabo , pgsql-performance@postgresql.org Subject: Re: Effects of cascading references in foreign keys In-reply-to: <20051029160527.GA80135@winnie.fuhr.org> References: <87acgszihk.fsf@nb-aspire.bettercom.de> <20051029142432.GA79557@winnie.fuhr.org> <20051029144947.GB21068@wolff.to> <20051029160527.GA80135@winnie.fuhr.org> Comments: In-reply-to Michael Fuhr message dated "Sat, 29 Oct 2005 10:05:27 -0600" Date: Sat, 29 Oct 2005 14:01:58 -0400 Message-ID: <11904.1130608918@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.006 required=5 tests=[AWL=0.006] X-Spam-Score: 0.006 X-Spam-Level: X-Archive-Number: 200510/457 X-Sequence-Number: 15225 Michael Fuhr writes: > On Sat, Oct 29, 2005 at 09:49:47AM -0500, Bruno Wolff III wrote: >> It looks like this feature was added last May, so I think it only applies >> to 8.1. > Earlier versions appear to have at least some kind of optimization. Yeah. IIRC, for quite some time we've had tests inside the FK update triggers to not bother to search the other table if the key value hasn't changed. What we did in 8.1 was to push that test further upstream, so that the trigger event isn't even queued if the key value hasn't changed. (This is why you don't see the trigger shown as being called even once.) Looking at this, I wonder if there isn't a bug or at least an inefficiency in 8.1. The KeysEqual short circuit tests are still there in ri_triggers.c; aren't they now redundant with the test in triggers.c? And don't they need to account for the special case mentioned in the comment in triggers.c, that the RI check must still be done if we are looking at a row updated by the same transaction that created it? regards, tom lane