X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B17824763EF for ; Sun, 4 May 2003 12:22:10 -0400 (EDT) Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) by postgresql.org (Postfix) with SMTP id E35CD475F00 for ; Sun, 4 May 2003 12:22:09 -0400 (EDT) Received: (qmail 55052 invoked by uid 1001); 4 May 2003 16:22:14 -0000 Date: Sun, 4 May 2003 11:22:14 -0500 From: "Jim C. Nasby" To: Manfred Koizar Cc: Tom Lane , pgsql-performance@postgresql.org Subject: Re: More tablescanning fun Message-ID: <20030504112214.V66185@flake.decibel.org> Reply-To: jim@nasby.net References: <20030424183817.A66185@flake.decibel.org> <3660.1051228710@sss.pgh.pa.us> <20030424235924.B66185@flake.decibel.org> <13549.1051248190@sss.pgh.pa.us> <20030425093800.C66185@flake.decibel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: ; from mkoi-pg@aon.at on Wed, Apr 30, 2003 at 04:14:46PM +0200 X-Operating-System: FreeBSD 4.8-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net X-Spam-Status: No, hits=-39.4 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,SIGNATURE_SHORT_SPARSE, USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200305/40 X-Sequence-Number: 1819 On Wed, Apr 30, 2003 at 04:14:46PM +0200, Manfred Koizar wrote: > On Fri, 25 Apr 2003 09:38:01 -0500, "Jim C. Nasby" > wrote: > >In this case, the interpolation can't be at fault, because correlation > >is 1 (unless the interpolation is backwards, but that doesn't appear to > >be the case). > > But your index has 3 columns which causes the index correlation to be > assumed as 1/3. So the interpolation uses 1/9 (correlation squared) > and you get a cost estimation that almost equals the upper bound. Hmm... interesting... maybe it would also be a good idea to expand ANALYZE so that it will analyze actual index correlation? ie: in this case, it would notice that the index on project_id, id, date is highly correlated, across all 3 columns. Supporting something close to a real clustered index would also work as well, since the optimizer would treat that case differently (essentially as a combination between an index scan but doing a seq. scan within each page). -- Jim C. Nasby (aka Decibel!) jim@nasby.net Member: Triangle Fraternity, Sports Car Club of America 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?"