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

Поиск
Список
Период
Сортировка
От Kashmira Patel \(kupatel\)
Тема Re: Question about index scan vs seq scan when using count()
Дата
Msg-id 18AE59788A3FC640A367E5652E664D800199BEE8@xmb-sjc-237.amer.cisco.com
обсуждение исходный текст
Ответ на Question about index scan vs seq scan when using count()  ("Kashmira Patel \(kupatel\)" <kupatel@cisco.com>)
Ответы Re: Question about index scan vs seq scan when using count()  (Andrew Sullivan <ajs@crankycanuck.ca>)
Список 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


В списке pgsql-sql по дате отправления:

Предыдущее
От: Andrew Sullivan
Дата:
Сообщение: Re: Question about index scan vs seq scan when using count()
Следующее
От: "Kashmira Patel \(kupatel\)"
Дата:
Сообщение: Re: Question about index scan vs seq scan when using count()