Re: "SELECT .. WHERE NOT IN" query running for hours

Поиск
Список
Период
Сортировка
От Mladen Gogala
Тема Re: "SELECT .. WHERE NOT IN" query running for hours
Дата
Msg-id 4D2B41C2.8020605@vmsinfo.com
обсуждение исходный текст
Ответ на Re: "SELECT .. WHERE NOT IN" query running for hours  (Γιωργος Βαλκανας <lebiathan@gmail.com>)
Ответы Re: "SELECT .. WHERE NOT IN" query running for hours  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-performance
Γιωργος Βαλκανας wrote:
>
> Are there any particular semantics for the "NOT IN" statement that
> cause the correlated query to execute for every row of the outter
> query, as opposed to the "NOT EXISTS" ? Or are there any other
> practical reasons, related to "IN / NOT IN", for this to be happening?
> Or is it simply due to implementation details of each RDBMS? I guess
> the former (or the 2nd one), since, as you say, this is common in most
> databases, but I would most appreciate an answer to clarify this.
>
> Thanks again!
>
> Best regards,
> George
>
>
>

Well, I really hoped that Bruce, Robert or Greg would take on this one,
but since there are no more qualified takers, I'll take a shot at this
one. For the "NOT IN (result of a correlated sub-query)", the sub-query
needs to be executed for every row matching the conditions on the
driving table, while the   !EXISTS is just a complement of join. It's
all in the basic set theory which serves as a model for the relational
databases.

--

Mladen Gogala
Sr. Oracle DBA
1500 Broadway
New York, NY 10036
(212) 329-5251
http://www.vmsinfo.com
The Leader in Integrated Media Intelligence Solutions




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

Предыдущее
От: Mike Broers
Дата:
Сообщение: Re: plan question - query with order by and limit not choosing index depends on size of limit, table
Следующее
От: Scott Carey
Дата:
Сообщение: Re: "SELECT .. WHERE NOT IN" query running for hours