Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 90DB39FB59B for ; Sun, 6 May 2007 21:36:04 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 54118-04 for ; Sun, 6 May 2007 21:35:55 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 0E3AA9FB571 for ; Sun, 6 May 2007 21:36:00 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l470ZuoN018315; Sun, 6 May 2007 20:35:57 -0400 (EDT) To: robins@pobox.com cc: pgsql-performance@postgresql.org, "Paul Smith" Subject: Re: Index not being used in sorting of simple table In-reply-to: <36af4bed0705060537n38996591u1cab44fa067a4fea@mail.gmail.com> References: <3292.1178293381@sss.pgh.pa.us> <36af4bed0705060537n38996591u1cab44fa067a4fea@mail.gmail.com> Comments: In-reply-to Robins message dated "Sun, 06 May 2007 18:07:45 +0530" Date: Sun, 06 May 2007 20:35:56 -0400 Message-ID: <18314.1178498156@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/66 X-Sequence-Number: 24456 Robins writes: > There is one thing though, that I couldn't really understand. Considering > that A's correlation in pg_stats being very high compared to B, isn't it 'a > better candidate' for a sequential scan as compared to B in this scenario ? No, high correlation reduces the cost of an indexscan but doesn't do anything much for a seqscan-and-sort. (Actually, I suppose it could help by reducing the number of initial runs to be merged, but that's not an effect the planner knows about.) The interesting point is that Paul shows SELECT tablename, attname, correlation FROM pg_stats where tablename='x'; x | a | 0.977819 x | b | 0.78292 when his initial verbal description indicated that b should have the better correlation. So that's something else odd about this case. regards, tom lane