pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Prasanth <dbadmin@nqadmin.com>
To: pgsql-admin@postgresql.org
Subject: Query Plan - Index Scan & Seq Scan
Date: Thu, 12 May 2005 10:05:16 -0500
Message-ID: <428370AC.3070207@nqadmin.com> (raw)

When joining two tables the query plan is doing a seq scan rather than index
scan. I do have indexes on the columns used for joining the tables.

Example:
SELECT a.id FROM a, b WHERE a.id = b.id;

                                       QUERY PLAN
-----------------------------------------------------------------------------------------
 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. After adding the new
records the planner is going for a seq scan while doing the join.

Is there any tunning I can do so that the query planner would do a index scan?

I did a vacuum analyze but no change.

Thanks,
-Prasanth.



view thread (14+ messages)  latest in thread

Message-ID: <428370AC.3070207@nqadmin.com>
Permalink:  ../428370AC.3070207@nqadmin.com/
Also on:    postgresql.org/message-id/428370AC.3070207@nqadmin.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: dbadmin@nqadmin.com
  Subject: Re: Query Plan - Index Scan & Seq Scan
  In-Reply-To: <428370AC.3070207@nqadmin.com>
  References: <428370AC.3070207@nqadmin.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox