Re: sub-query optimization
От | Brad Hilton |
---|---|
Тема | Re: sub-query optimization |
Дата | |
Msg-id | 1045247931.29968.28.camel@aragorn.vpop.net обсуждение исходный текст |
Ответ на | sub-query optimization (Brad Hilton <bhilton@vpop.net>) |
Список | pgsql-sql |
On Fri, 2003-02-14 at 10:22, 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 > ) To add one more detail: in simplifying my query for the list, I should have said: article_categories.category_id = 0 instead of article_categories.category_id is NULL Then, with an index on article_categories (category_id) you get the following results for the two queries: Without adding the "articles" table to the inner query: 1329 msec With the "articles" table in the inner query: 0.28 msec! That highlights the difference a bit more dramatically. Any ideas? Thanks, -Brad
В списке pgsql-sql по дате отправления: