X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 26389475EF0 for ; Fri, 9 May 2003 09:30:11 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 25524475EC9 for ; Fri, 9 May 2003 09:30:10 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h49DUCU6000250; Fri, 9 May 2003 09:30:12 -0400 (EDT) To: Achilleus Mantzios Cc: pgsql-performance@postgresql.org Subject: Re: An unresolved performance problem. In-reply-to: References: Comments: In-reply-to Achilleus Mantzios message dated "Fri, 09 May 2003 16:22:23 -0200" Date: Fri, 09 May 2003 09:30:12 -0400 Message-ID: <249.1052487012@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES 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/115 X-Sequence-Number: 1894 Achilleus Mantzios writes: > On Fri, 9 May 2003, Tom Lane wrote: >> Well, that's suggestive, isn't it? What about the remaining columns? > The index is defined as: > status_all btree (assettable, assetidval, appname, apptblname, status, > isvalid) > And correlations are: > attname | correlation > -------------+------------- > assettable | 1 > assetidval | 0.125902 > appname | 0.942771 > apptblname | 0.928761 > status | 0.443405 > isvalid | 0.970531 Actually, thinking twice about it, I'm not sure if the correlations of the righthand columns mean anything. If the table were perfectly ordered by the index, you'd expect righthand values to cycle through their range for each lefthand value, and so they'd show low correlations. The fact that most of the columns show high correlation makes me think that they are not independent --- is that right? But anyway, I'd say that yes this table is probably quite well ordered by the index. You could just visually compare the results of select * from tab select * from tab order by assettable, assetidval, appname, apptblname, status, isvalid to confirm this. And that tells us where the problem is: the code is estimating a low index correlation where it should be estimating a high one. If you don't mind running a nonstandard version of Postgres, you could try making btcostestimate() in src/backend/utils/adt/selfuncs.c estimate the indexCorrelation as just varCorrelation, instead of varCorrelation / nKeys. This is doubtless an overcorrection in the other direction (which is why it hasn't been done in the official sources) but it's probably better than what's there, at least for your purposes. regards, tom lane