| От | Tom Lane |
|---|---|
| Тема | Re: Why is this query running slowly? |
| Дата | |
| Msg-id | 10696.1316096777@sss.pgh.pa.us обсуждение |
| Ответ на | Re: Why is this query running slowly? (Yang Zhang <yanghatespam@gmail.com>) |
| Ответы |
Re: Why is this query running slowly?
|
| Список | pgsql-general |
Yang Zhang <yanghatespam@gmail.com> writes:
> On Thu, Sep 15, 2011 at 1:22 AM, Tomas Vondra <tv@fuzzy.cz> wrote:
>> [ use a left join instead of NOT IN ]
> This worked great, thank you. Too bad the planner isn't smart enough
> to do this yet!
It never will be, because they're not equivalent queries. NOT IN has
different (and very hard-to-optimize) behavior in the face of NULLs in
the right-hand table.
The moral of the story is avoid NOT IN. You could use NOT EXISTS,
which is less of a notational change than recasting as a left join.
regards, tom lane
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера