Re: Bad query plan

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Bad query plan
Дата
Msg-id 12708.1311523344@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Bad query plan  (Дмитрий Васильев <dmitry.vasil@gmail.com>)
Список pgsql-performance
=?KOI8-R?B?5M3J1NLJyiD3wdPJzNjF1w==?= <dmitry.vasil@gmail.com> writes:
> explain analyze insert into large(id) select id from small where id
> not in(select id from large);
> [ crummy plan ]
> explain analyze insert into large(id) select id from small where not
> exists (select id from large l where small.id=l.id);
> [ better plan ]
> Both queries are semantically the same.

No, they are not.  NOT IN is hard to optimize because it has strange
behaviors with nulls in the data.  Use the NOT EXISTS formulation.

            regards, tom lane

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

Предыдущее
От: Дмитрий Васильев
Дата:
Сообщение: Bad query plan
Следующее
От: Adarsh Sharma
Дата:
Сообщение: Restore database after drop command