Re: Question about index scan vs seq scan when using count() - Mailing list pgsql-sql

From Kashmira Patel \(kupatel\)
Subject Re: Question about index scan vs seq scan when using count()
Date
Msg-id 18AE59788A3FC640A367E5652E664D800199BF22@xmb-sjc-237.amer.cisco.com
Whole thread Raw
In response to Question about index scan vs seq scan when using count()  ("Kashmira Patel \(kupatel\)" <kupatel@cisco.com>)
List pgsql-sql
This is how I created the index:

CREATE INDEX msgid_index ON vm_message(msgid);

I guess it doing this because its a small table then. I will try putting
more values.

Thanks,
Kashmira

-----Original Message-----
From: pgsql-sql-owner@postgresql.org
[mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Andrew Sullivan
Sent: Thursday, February 23, 2006 2:47 PM
To: pgsql-sql@postgresql.org
Subject: Re: [SQL] Question about index scan vs seq scan when using
count()

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@crankycanuck.ca
"The year's penultimate month" is not in truth a good way of saying
November.    --H.W. Fowler

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate      subscribe-nomail command to
majordomo@postgresql.orgso that your      message can get through to the mailing list cleanly 


pgsql-sql by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re: Question about index scan vs seq scan when using count()
Next
From: "Owen Jacobson"
Date:
Subject: Re: Question about index scan vs seq scan when using count()