X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4EA51475F1B for ; Thu, 17 Apr 2003 10:26:40 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 9557E475ECE for ; Thu, 17 Apr 2003 10:26:39 -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 h3HEQhU6010433; Thu, 17 Apr 2003 10:26:44 -0400 (EDT) To: Rajesh Kumar Mallah Cc: pgsql-sql@postgresql.org Subject: Re: planner question.. In-reply-to: <200304171404.10306.mallah@trade-india.com> References: <200304171404.10306.mallah@trade-india.com> Comments: In-reply-to Rajesh Kumar Mallah message dated "Thu, 17 Apr 2003 14:04:10 +0530" Date: Thu, 17 Apr 2003 10:26:43 -0400 Message-ID: <10432.1050589603@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_00,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: 200304/270 X-Sequence-Number: 12971 Rajesh Kumar Mallah writes: > For a distribution of data like below why does the planner > choses to do an index scan by default for source = 'REGIS' when > 50% > of the rows are having source='REGIS'. Are there a huge number of dead rows in the table? ("vacuum verbose" would give some info) The given result seems suspect; an indexscan couldn't possibly read >50% of the rows in less than a quarter of the time for a seqscan. Unless (a) the table contains vast amounts of empty space that the seqscan has to slog through, or (b) your second measurement is bogus due to caching performed by the first measurement. Also, might the table be in order by the "source" column? A sufficiently high correlation might have persuaded the planner to try an indexscan even if point (a) isn't true. regards, tom lane