Re: Question about index scan vs seq scan when using count()

From: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Question about index scan vs seq scan when using count()
Date: 2006-02-23 22:47:23
Message-ID: 20060223224723.GG11392@phlogiston.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, Feb 23, 2006 at 02:25:34PM -0800, Kashmira Patel (kupatel) wrote:
>
> [Kashmira] I did do an EXPLAIN ANALYZE as well, it also showed a
> sequential scan. The table has about 600+ rows, with around 6 of them
> matching the given id. Wouldn't an index scan be faster in this case?

EXPLAIN ANALYSE will always choose the same plan as EXPLAIN. The
difference is that it shows you the estimate and actual.

I am surprised you're getting a seqscan for that, though. Is there
something about the index you're not telling us?

Is your system tuned correctly? Maybe 600 rows is so small that a
seqscan's just as fast.

A

--
Andrew Sullivan | ajs(at)crankycanuck(dot)ca
"The year's penultimate month" is not in truth a good way of saying
November.
--H.W. Fowler

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Kashmira Patel (kupatel) 2006-02-23 22:55:59 Re: Question about index scan vs seq scan when using count()
Previous Message Kashmira Patel (kupatel) 2006-02-23 22:35:16 Re: Question about index scan vs seq scan when using count()