X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E9F27D1D2F7 for ; Fri, 13 Feb 2004 15:56:45 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 30042-08 for ; Fri, 13 Feb 2004 11:56:44 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id DD73DD1D851 for ; Fri, 13 Feb 2004 11:56:39 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1DFuigI002663; Fri, 13 Feb 2004 10:56:44 -0500 (EST) To: Stephan Szabo Cc: Rod Taylor , ow , pgsql-sql@postgresql.org Subject: Re: 7.4 - FK constraint performance In-reply-to: <20040213073852.K20792@megazone.bigpanda.com> References: <20040213010341.95282.qmail@web60801.mail.yahoo.com> <25808.1076634636@sss.pgh.pa.us> <1076640825.10896.12.camel@jester> <27443.1076646336@sss.pgh.pa.us> <20040213065530.M19832@megazone.bigpanda.com> <2455.1076686047@sss.pgh.pa.us> <20040213073852.K20792@megazone.bigpanda.com> Comments: In-reply-to Stephan Szabo message dated "Fri, 13 Feb 2004 07:49:59 -0800" Date: Fri, 13 Feb 2004 10:56:44 -0500 Message-ID: <2662.1076687804@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/151 X-Sequence-Number: 16842 Stephan Szabo writes: > On Fri, 13 Feb 2004, Tom Lane wrote: >> I was looking at that last night. It seems like we could add a LIMIT at >> least in some contexts. In the case at hand, we're just going to error >> out immediately if we find a matching row, and so there's no need for >> FOR UPDATE, is there? > I think there still is, because a not yet committed transaction could have > deleted them all in which case I think the correct behavior is to wait and > if that transaction commits allow the action and if it rolls back to > error. Good point. Okay, we can't put in a LIMIT. But we could still hack the planner to prefer a fast-start plan by passing an out-of-band tuple fraction, for those RI plans where it's appropriate. That would not affect correctness. >> However, I'm not sure it would help the OP anyway. With the stats he >> had, the planner would still take a seqscan, because it's going to >> expect that it can find a match by probing the first ten or so rows of >> the first page. With anything close to the normal cost parameters, >> that's going to look more expensive than an index probe. s/more expensive/less expensive/ ... need more caffeine obviously ... regards, tom lane