X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4652B53465 for ; Tue, 29 Mar 2005 16:31:59 +0100 (BST) 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 88107-04 for ; Tue, 29 Mar 2005 15:31:57 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id A576553425 for ; Tue, 29 Mar 2005 16:31:56 +0100 (BST) 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 j2TFVonD022528; Tue, 29 Mar 2005 10:31:50 -0500 (EST) To: Simon Riggs Cc: Stephan Szabo , Karim A Nassar , Christopher Kings-Lynne , pgsql-performance@postgresql.org Subject: Re: Delete query takes exorbitant amount of time In-reply-to: <1112109880.11750.977.camel@localhost.localdomain> References: <1112095776.11750.958.camel@localhost.localdomain> <20050329054714.V50612@megazone.bigpanda.com> <20050329061837.A51620@megazone.bigpanda.com> <21616.1112108201@sss.pgh.pa.us> <1112109880.11750.977.camel@localhost.localdomain> Comments: In-reply-to Simon Riggs message dated "Tue, 29 Mar 2005 16:24:40 +0100" Date: Tue, 29 Mar 2005 10:31:50 -0500 Message-ID: <22527.1112110310@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/635 X-Sequence-Number: 11340 Simon Riggs writes: > If action is NO ACTION or RESTRICT then > we need to SELECT at most 1 row that matches the criteria > which means we can use LIMIT 1 > If action is CASCADE, SET NULL, SET DEFAULT then > we need to UPDATE or DELETE all rows that match the criteria > which means we musnt use LIMIT and need to use FOR UPDATE Huh? UPDATE/DELETE don't use FOR UPDATE. I think you have failed to break down the cases sufficiently. In particular it matters which side of the RI constraint you are working from ... regards, tom lane