From: | "Kashmira Patel \(kupatel\)" <kupatel(at)cisco(dot)com> |
---|---|
To: | "Andrew Sullivan" <ajs(at)crankycanuck(dot)ca>, <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Question about index scan vs seq scan when using count() |
Date: | 2006-02-23 22:25:34 |
Message-ID: | 18AE59788A3FC640A367E5652E664D800199BEE8@xmb-sjc-237.amer.cisco.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
> For example: I have a table vm_message with an index on column msgid.
> Will the following do a sequential scan or an index?
>
> select count(*) from vm_message where msgid = 3;
How much of the table is that? How many rows? EXPLAIN ANALYSE will
tell you if you have the right plan (estimate vs. actual). The real
question is, are you sure an indexscan is faster?
[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?
Also, I have two more indices defined on this table, for other types of
queries I do on it. Would they be causing a problem? In general, is
there a rule of thumb as to when an index scan would be better than a
sequential scan?
Thanks,
Kashmira
From | Date | Subject | |
---|---|---|---|
Next Message | Kashmira Patel (kupatel) | 2006-02-23 22:35:16 | Re: Question about index scan vs seq scan when using count() |
Previous Message | Andrew Sullivan | 2006-02-23 22:12:23 | Re: Question about index scan vs seq scan when using count() |