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 EC5863A2B41 for ; Fri, 29 Oct 2004 00:47:04 +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 91701-04 for ; Thu, 28 Oct 2004 23:46:56 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) by svr1.postgresql.org (Postfix) with ESMTP id 2388D3A2B10 for ; Fri, 29 Oct 2004 00:46:58 +0100 (BST) Received: by flake.decibel.org (Postfix, from userid 1001) id A93A71C900; Thu, 28 Oct 2004 23:46:58 +0000 (GMT) Date: Thu, 28 Oct 2004 18:46:58 -0500 From: "Jim C. Nasby" To: Tom Lane Cc: John Meinel , pgsql-performance@postgresql.org Subject: Re: Sequential Scan with LIMIT Message-ID: <20041028234658.GI55164@decibel.org> References: <417C023F.1080502@johnmeinel.com> <17689.1098648713@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <17689.1098648713@sss.pgh.pa.us> X-Operating-System: FreeBSD 4.10-RELEASE-p3 i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/465 X-Sequence-Number: 8941 On Sun, Oct 24, 2004 at 04:11:53PM -0400, Tom Lane wrote: > But the LIMIT will cut the cost of the seqscan case too. Given the > numbers you posit above, about one row in five will have 'myval', so a > seqscan can reasonably expect to hit the first matching row in the first > page of the table. This is still cheaper than doing an index scan > (which must require reading at least one index page plus at least one > table page). > > The test case you are showing is probably suffering from nonrandom > placement of this particular data value; which is something that the > statistics we keep are too crude to detect. Isn't that exactly what pg_stats.correlation is? -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?"