Re: Re-Reason of Slowness of Query
От | Shaun Thomas |
---|---|
Тема | Re: Re-Reason of Slowness of Query |
Дата | |
Msg-id | 4D89F6E5.7010803@peak6.com обсуждение исходный текст |
Ответ на | Re-Reason of Slowness of Query (Adarsh Sharma <adarsh.sharma@orkash.com>) |
Ответы |
Re: Re-Reason of Slowness of Query
|
Список | 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: EXPLAIN ANALYZE SELECT p.crawled_page_id FROM page_content p WHERE NOT EXISTS ( SELECT 1 FROM clause2 c WHERE c.source_id = p.crawled_page_id ) GROUP BY p.crawled_page_id; Or if you like the cleaner query without a sub-select: EXPLAIN ANALYZE SELECT p.crawled_page_id FROM page_content p LEFT JOIN clause2 c ON (c.source_id = p.crawled_page_id) WHERE c.source_id IS NULL GROUP BY p.crawled_page_id; -- Shaun Thomas OptionsHouse | 141 W. Jackson Blvd. | Suite 800 | Chicago IL, 60604 312-676-8870 sthomas@peak6.com ______________________________________________ See http://www.peak6.com/email_disclaimer.php for terms and conditions related to this email
В списке pgsql-performance по дате отправления: