Re: sub-query optimization

Поиск
Список
Период
Сортировка
Искать
От
jasiek@serwer.skawsoft.com.pl
Тема
Re: sub-query optimization
Дата
Msg-id
20030214192113.GA26987@serwer
Ответ на
Список
Дерево обсуждения
Re: sub-query optimization Tomasz Myrta <jasiek@klaster.net>
On Fri, Feb 14, 2003 at 10:22:19AM -0800, Brad Hilton wrote:
> Hello,
>
> I am hoping someone can help explain why modifying the following query
> can effect such a huge change in speed.  The query is:
>
>       select * from articles
>       where exists
>        ( select 1 from article_categories
>          where
>          article_categories.article_id = articles.id and
>          article_categories.category_id is null
>        )

Can you test these two queries?select * from (select article_id from article_categories where category_id is null  group by article_id) X   join articles using (article_id);
 select  from  article_categories  join articles using (article_id) where category_id is null  group by 
Above queries will need index on article_idI'm not sure if it helps, but they are the only solutions in mymind ;-)
Can you say anything about data statistics in your tables? Howmany rows are with category_id=null?
I looked into query definition once again. Your query doesn't makesense - article_categories have not null category_id... What do you reallywant to do?

Regards,
Tomasz Myrta

В списке pgsql-sql по дате отправления
От: Tomasz Myrta
Дата:
Сообщение: Re: sub-query optimization
От: Eduardo
Дата:
Сообщение: Re: PL/PGSQL EDITOR
FAQ