Re: BUG #3979: SELECT DISTINCT slow even on indexed column

Поиск
Список
Период
Сортировка
От Simon Riggs
Тема Re: BUG #3979: SELECT DISTINCT slow even on indexed column
Дата
Msg-id 1203934747.4252.10.camel@ebony.site
обсуждение исходный текст
Ответ на BUG #3979: SELECT DISTINCT slow even on indexed column  ("David Lee" <david_lee@bigfix.com>)
Список pgsql-bugs
On Thu, 2008-02-21 at 23:34 +0000, David Lee wrote:

> I ran EXPLAIN and it showed that the path did not use the index, so I ran:

Your expectation that this would use an index is unfortunately not
correct.

We need to check visibility on the table rows to do the query. We choose
to do this by doing a sort and then a unique operation. That's the most
efficient plan when there are potentially many unique values.

In the case you mention it would be faster for us to skip through the
index retrieving at most one row from each value in the index. We don't
currently do that, but we could. However that plan would be restricted
only to queries of the form
  SELECT DISTINCT column-list-of-index FROM table;

so its probably not going to be optimised anytime soon.

--
  Simon Riggs
  2ndQuadrant  http://www.2ndQuadrant.com

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

Предыдущее
От: "Yann"
Дата:
Сообщение: BUG #3986: Error ts_vector with UTF8 WS2003
Следующее
От: "chandra"
Дата:
Сообщение: BUG #3987: Not checking the password