Re: Re-Reason of Slowness of Query

Поиск
Список
Период
Сортировка
От tv@fuzzy.cz
Тема Re: Re-Reason of Slowness of Query
Дата
Msg-id 557a8c61e87e5e54ae205daadd8f0ca4.squirrel@sq.gransy.com
обсуждение исходный текст
Ответ на Re: Re-Reason of Slowness of Query  (Shaun Thomas <sthomas@peak6.com>)
Ответы Re: Re-Reason of Slowness of Query  (Shaun Thomas <sthomas@peak6.com>)
Re: Re-Reason of Slowness of Query  (Adarsh Sharma <adarsh.sharma@orkash.com>)
Список pgsql-performance
> On 03/23/2011 04:17 AM, Adarsh Sharma wrote:
>
>> explain analyze select distinct(p.crawled_page_id) from page_content
>> p where NOT EXISTS (select 1 from clause2 c where c.source_id =
>> p.crawled_page_id);
>
> You know... I'm surprised nobody has mentioned this, but DISTINCT is
> very slow unless you have a fairly recent version of Postgres that
> replaces it with something faster. Try this:

Nobody mentioned that because the explain plan already uses hash aggregate
(instead of the old sort)

 HashAggregate  (cost=100278.16..104104.75 rows=382659 width=8) (actual
time=7047.259..7050.261 rows=72 loops=1)

which means this is at least 8.4. Plus the 'distinct' step uses less than
1% of total time, so even if you improve it the impact will be minimal.

regards
Tomas


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

Предыдущее
От: Uwe Bartels
Дата:
Сообщение: Re: buffercache/bgwriter
Следующее
От: Shaun Thomas
Дата:
Сообщение: Re: Re-Reason of Slowness of Query