pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Scott Marlowe <smarlowe@g2switchworks.com>
To: dbadmin@nqadmin.com
Cc: pgsql-admin@postgresql.org
Subject: Re: Query Plan - Index Scan & Seq Scan
Date: Thu, 12 May 2005 10:51:26 -0500
Message-ID: <1115913086.22291.1.camel@state.g2switchworks.com> (raw)
In-Reply-To: <42837B95.2090908@nqadmin.com>
References: <428370AC.3070207@nqadmin.com>
	<1115911416.3868.265.camel@state.g2switchworks.com>
	<42837B95.2090908@nqadmin.com>

On Thu, 2005-05-12 at 10:51, Prasanth wrote:
> I agree with you.
> 
> But I have the where conditions on the tables I was expecting the planner to
> user index scan but it went for seq scan.
> 
> I did a little testing using what you said.
> 
> Below are the results.
> 
> SELECT a.id FROM a,b WHERE a.id = b.id AND a.code >2 AND b.account_id = 16221;
> 
> Total runtime: 18194.936 ms
> 
> Then I set the seqscan off and ran the same query.
> 
> Total runtime: 27.554 ms

Good!  This tells us two things, 1:  Your database can use the indexes
(sometimes indexes can't be used for various reasons, which are quickly
disappearing by the way.) and 2:  Your database is making the wrong
choice about when to use a seq scan versus an index.

What does the explain analyze output from that query say about row
estimates versus actual rows returned?



view thread (14+ messages)  latest in thread

Message-ID: <1115913086.22291.1.camel@state.g2switchworks.com>
Permalink:  ../1115913086.22291.1.camel@state.g2switchworks.com/
Also on:    postgresql.org/message-id/1115913086.22291.1.camel@state.g2switchworks.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: smarlowe@g2switchworks.com, dbadmin@nqadmin.com
  Subject: Re: Query Plan - Index Scan & Seq Scan
  In-Reply-To: <1115913086.22291.1.camel@state.g2switchworks.com>
  References: <428370AC.3070207@nqadmin.com> <1115911416.3868.265.camel@state.g2switchworks.com> <42837B95.2090908@nqadmin.com> <1115913086.22291.1.camel@state.g2switchworks.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