Re: slow query - where not in
| От | Michael Paesold |
|---|---|
| Тема | Re: slow query - where not in |
| Дата | |
| Msg-id | 028e01c2f54a$9af3d010$3201a8c0@beeblebrox обсуждение исходный текст |
| Ответ на | slow query - where not in (Jeremiah Elliott <jelliott@artcobell.com>) |
| Ответы |
Re: slow query - where not in
|
| Список | pgsql-performance |
Bruno Wolff III <bruno@wolff.to> wrote:
> Jeremiah Elliott <jelliott@artcobell.com> wrote:
> > here is the query that is killing me:
> >
> > select shoporder from sodetailtabletrans where shoporder not in(select
> > shoporder from soheadertable)
>
> If there are no null values for shoporder in soheadertable or
> sodetailtabletrans you can use not exists instead of not in:
> select shoporder from sodetailtabletrans where shoporder not exists(select
> shoporder from soheadertable)
I think this should rather be:
SELECT shoporder FROM sodetailtabletrans
WHERE NOT EXISTS (
SELECT 1 FROM soheadertable
WHERE soheadertable.shoporder = sodetailtabletrans.shoporder
)
Regards,
Michael Paesold
В списке pgsql-performance по дате отправления: