Re: group by will not use an index?

Поиск
Список
Период
Сортировка
От Scott Marlowe
Тема Re: group by will not use an index?
Дата
Msg-id 1168386124.20602.185.camel@state.g2switchworks.com
обсуждение исходный текст
Ответ на group by will not use an index?  (tsuraan <tsuraan@gmail.com>)
Ответы Re: group by will not use an index?
Список pgsql-performance
On Tue, 2007-01-09 at 17:05, tsuraan wrote:
> I have a table of messages with paths and inserted dates (among other
> things), like so:
>
> CREATE TABLE Messages (
>     msgkey BIGSERIAL PRIMARY KEY,
>     path TEXT NOT NULL,
>     inserted TIMESTAMP WITHOUT TIMEZONE DEFAULT NOW()
> );
>
> I run a query to determine which days actually saw emails come in,
> like so:
>
> SELECT DATE(inserted) FROM Messages GROUP BY DATE(inserted);

You're probably under the mistaken impression that PostgreSQL and can
retrieve all the data it needs from the index alone.  It can't.  Anytime
postgresql gets an index reference, it has to then visit the actual
table file to grab the individual entry.  That's because indexes don't
store mvcc visibility information, and due to the problems locking both
indexes and tables together would present, probably won't any time soon.

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

Предыдущее
От: "Gregory S. Williamson"
Дата:
Сообщение: Re: Horribly slow query/ sequential scan
Следующее
От: Brian Herlihy
Дата:
Сообщение: Re: group by will not use an index?