Re: select distinct and index usage

Поиск
Список
Период
Сортировка
От Gregory Stark
Тема Re: select distinct and index usage
Дата
Msg-id 87iqytfcbi.fsf@oxford.xeocode.com
обсуждение исходный текст
Ответ на Re: select distinct and index usage  ("David Wilson" <david.t.wilson@gmail.com>)
Ответы Re: select distinct and index usage
Список pgsql-general
"David Wilson" <david.t.wilson@gmail.com> writes:

> I appreciate the responses so far! I'm used to several minutes for
> some of the complex queries on this DB, but 12.5 minutes for a select
> distinct just seems wrong. :)

You could try changing it to the equivalent GROUP BY query. The planner,
unfortunately, doesn't know they're equivalent and has two separate sets of
plans available. In this case where there are only 4,000 distinct values out
of 75M original records you might find a HashAggregate plan, which the planner
doesn't know can be used for DISTINCT, best. You might have to raise work_mem
before the planner feels a hash will fit.

--
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com
  Ask me about EnterpriseDB's RemoteDBA services!

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

Предыдущее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: [pgsql-advocacy] pgus-general now up
Следующее
От: Mike Ginsburg
Дата:
Сообщение: Most Occurring Value