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 6297DD1D85F for ; Fri, 13 Feb 2004 07:22:24 +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 70326-04 for ; Fri, 13 Feb 2004 03:22:23 -0400 (AST) Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net [194.217.242.85]) by svr1.postgresql.org (Postfix) with ESMTP id 3CEB7D1D82E for ; Fri, 13 Feb 2004 03:22:22 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-35.mail.demon.net with esmtp (Exim 3.35 #1) id 1ArXeY-000700-0Z; Fri, 13 Feb 2004 07:22:22 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id 41C6A16930; Fri, 13 Feb 2004 07:22:20 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 5829C16433; Fri, 13 Feb 2004 07:22:18 +0000 (GMT) From: Richard Huxton To: Tom Lane , Rod Taylor Subject: Re: 7.4 - FK constraint performance Date: Fri, 13 Feb 2004 07:22:17 +0000 User-Agent: KMail/1.5 Cc: ow , pgsql-sql@postgresql.org References: <20040213010341.95282.qmail@web60801.mail.yahoo.com> <1076640825.10896.12.camel@jester> <27443.1076646336@sss.pgh.pa.us> In-Reply-To: <27443.1076646336@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402130722.17663.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/139 X-Sequence-Number: 16830 On Friday 13 February 2004 04:25, Tom Lane wrote: > Rod Taylor writes: > > Statistics say there are 10 values. Statistics list the 10 most common > > values (all of them). Given this, would it not be reasonable to assume > > that 239 is a recent addition (if there at all) to the table and not > > very common? > > We don't know that it's 239 when we make the plan. In order to know > that, we'd have to abandon caching of RI check query plans and re-plan > for each row. That strikes me as inevitably a losing proposition. In this precise example, could you not: 1. Check index for value 2. If found, seq-scan Of course that's only going to be a sensible thing to do if you're expecting one of two results: 1. Value not there 2. Lengthy seq-scan if it is there -- Richard Huxton Archonet Ltd