Re: Re-Reason of Slowness of Query

Поиск
Список
Период
Сортировка
От tv@fuzzy.cz
Тема Re: Re-Reason of Slowness of Query
Дата
Msg-id c054efdf315e1df9376b2646077ef805.squirrel@sq.gransy.com
обсуждение исходный текст
Ответ на Re: Re-Reason of Slowness of Query  (Adarsh Sharma <adarsh.sharma@orkash.com>)
Ответы Re: Re-Reason of Slowness of Query  (Chetan Suttraway <chetan.suttraway@enterprisedb.com>)
Список pgsql-performance
> I just want to retrieve that id 's from page_content which do not have
> any entry in clause2 table.

In that case the query probably does not work (at least the query you've
sent in the first post) as it will return even those IDs that have at
least one other row in 'clause2' (not matching the != condition). At least
that's how I understand it.

So instead of this

select distinct(p.crawled_page_id)
from page_content p, clause2 c where p.crawled_page_id != c.source_id ;

you should probably do this

select distinct(p.crawled_page_id)
from page_content p left join clause2 c on (p.crawled_page_id =
c.source_id) where (c.source_id is null);

I guess this will be much more efficient too.

regards
Tomas


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

Предыдущее
От: Vitalii Tymchyshyn
Дата:
Сообщение: Re: Re-Reason of Slowness of Query
Следующее
От: Chetan Suttraway
Дата:
Сообщение: Re: Re-Reason of Slowness of Query