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 CE5C7DB376 for ; Sat, 29 Oct 2005 08:10:33 -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 49301-05 for ; Sat, 29 Oct 2005 11:10:30 +0000 (GMT) Received: from h1.bettercom.de (h1.bettercom.de [213.239.194.41]) by svr1.postgresql.org (Postfix) with ESMTP id ABB09DB36F for ; Sat, 29 Oct 2005 08:10:31 -0300 (ADT) Received: (qmail 24038 invoked by uid 208); 29 Oct 2005 11:10:33 -0000 Received: from 213.39.147.134 by h1 (envelope-from , uid 0) with qmail-scanner-1.23 (clamdscan: 0.87. spamassassin: 3.04. Clear:RC:1(213.39.147.134):. Processed in 0.045217 secs); 29 Oct 2005 11:10:33 -0000 Received: from unknown (HELO nb-aspire.bettercom.de) ([213.39.147.134]) (envelope-sender ) by h1.bettercom.de (qmail-ldap-1.03) with SMTP for ; 29 Oct 2005 11:10:32 -0000 Received: (nullmailer pid 14010 invoked by uid 1000); Sat, 29 Oct 2005 11:10:32 -0000 Subject: Effects of cascading references in foreign keys X-PGP-Key: http://bettercom.de/misc/3A547DE6.asc X-Face: "d[&>8')a)wbF:+L#^<_cohnX6#m5RCCeKF/6_gD(iQ9bX?xe2~Aq*!')D(1ks`?YhomOYbL3R:{4e4a]qft_]<.q/Lf4hIr,`G+LX33&TYp}XGfe~^5m$28R"$C(EwnB\n8t To: pgsql-performance@postgresql.org From: Martin Lesser Date: Sat, 29 Oct 2005 13:10:31 +0200 Message-ID: <87acgszihk.fsf@nb-aspire.bettercom.de> User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4 (Jumbo Shrimp, linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.004 required=5 tests=[AWL=0.004] X-Spam-Score: 0.004 X-Spam-Level: X-Archive-Number: 200510/450 X-Sequence-Number: 15218 Which effects have UPDATEs on REFERENCEd TABLEs when only columns in the referenced table are updated which are not part of the FOREIGN KEY constraint? I have one "master"-table like create table t_master ( m_id serial primary key, m_fld1 ..., m_fld2 ..., ... ) The table above is referenced from several (~30) other tables, i.e. like create table t_detail ( d_ebid int REFERENCES t_master (m_id) ON UPDATE CASCADE ON DELETE CASCADE, d_fld1 ..., d_fld2 ..., ... ) All tables which reference t_master have appropriate indexes on the referencing columns, vacuum/analyze is done regularly (daily). Does an UPDATE of e.g. m_fld1 in t_master cause a 'lookup' in all tables which have a cascading update-rule or is this 'lookup' only triggered if the referenced column in t_master is explicitly updated? After removing some detail tables which are not longer needed we see an improvemed performance so at the moment it _looks_ like each update in t_master triggers a 'lookup' in each referencing table also if the referenced column (m_id) is not changed. I've read "If the row is updated, but the referenced column is not actually changed, no action is done." in the docs but it is not clear for me whether this "no action" really means "null action" and so the improved performance has other reasons. TIA, Martin