Re: Can this be indexed?

Поиск
Список
Период
Сортировка
От Tatsuo Ishii
Тема Re: Can this be indexed?
Дата
Msg-id 20041108.103959.32716752.t-ishii@sra.co.jp
обсуждение исходный текст
Ответ на Can this be indexed?  ("Net Virtual Mailing Lists" <mailinglists@net-virtual.com>)
Список pgsql-general
> Is there a way to create an index that would make this query be efficient
> and not perform a sequential scan?
>
> SELECT count(*) AS count,id FROM sometable GROUP BY id;
>
> .. I've considered creating a rule on this table which would put the
> results of this into another table anytime it is updated, but I thought
> there might be an easier way.

Sure. Try to create an index on id. Another way to improve this query
is to use HashAggregate (this is new in 7.4). Sometimes it is much
faster than group-by-using-index-scan. To enable HashAggregate
you might want to increase sort_mem.
--
Tatsuo Ishii

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re:
Следующее
От: "Gary L. Burnore"
Дата:
Сообщение: Re: Postresql RFD version 2.0 Help Wanted.