X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 27F12564BA for ; Thu, 12 May 2005 12:14:43 -0300 (ADT) 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 57644-08 for ; Thu, 12 May 2005 15:14:40 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id E857A556D3 for ; Thu, 12 May 2005 12:14:32 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4CFEUWr000887; Thu, 12 May 2005 11:14:30 -0400 (EDT) To: dbadmin@nqadmin.com Cc: pgsql-admin@postgresql.org Subject: Re: Query Plan - Index Scan & Seq Scan In-reply-to: <428370AC.3070207@nqadmin.com> References: <428370AC.3070207@nqadmin.com> Comments: In-reply-to Prasanth message dated "Thu, 12 May 2005 10:05:16 -0500" Date: Thu, 12 May 2005 11:14:30 -0400 Message-ID: <886.1115910870@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/148 X-Sequence-Number: 17577 Prasanth writes: > Hash Join (cost=13865.30..326413.23 rows=6451 width=18) > Hash Cond: ("outer".id = "inner".id) > -> Seq Scan on a (cost=0.00..125076.37 rows=6450937 width=18) > -> Hash (cost=10168.64..10168.64 rows=500664 width=4) > -> Seq Scan on b (cost=0.00..10168.64 rows=500664 width=4) > (5 rows) > The planner used to perform a index scan. I have added a lot of data in those > two tables. Right now both tables have millions of records. It is highly unlikely that you want an index scan for joining millions of records ... However, if you do have millions in both tables, why does the planner think there are only 500664 rows in b? Maybe you are overdue for ANALYZE. regards, tom lane