Re: select distinct and index usage

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: select distinct and index usage
Дата
Msg-id 20080408124839.GE5290@alvh.no-ip.org
обсуждение исходный текст
Ответ на Re: select distinct and index usage  (Gregory Stark <stark@enterprisedb.com>)
Список pgsql-general
Gregory Stark escribió:

> I thought our DISTINCT index scan does do that but it still has to read the
> index leaf pages sequentially. It doesn't back-track up the tree structure and
> refind the next key.

The way to back-track is to start the scan over from the root page down,
keeping a stack of parent pages as you go down (mainly because we need
to lock them in order, topmost first).  So it's not a particularly cheap
operation.  I'm not sure the situation with thousands of equal keys is
common enough to warrant adding all the code that would be needed to
implement the kind of "distinct scan" that you suggest, even though it
certainly is a nice idea.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

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

Предыдущее
От: Sim Zacks
Дата:
Сообщение: dirty select
Следующее
От: "Fernando Hevia"
Дата:
Сообщение: Re: Removing Context messages