correlated delete with "in" and "left outer join"

Поиск
Список
Период
Сортировка
От
Тема correlated delete with "in" and "left outer join"
Дата
Msg-id 2977.10.0.10.116.1077848779.squirrel@mail.linkify.com
обсуждение исходный текст
Ответы Re: correlated delete with "in" and "left outer join"  (Michael Glaesemann <grzm@myrealbox.com>)
Re: correlated delete with "in" and "left outer join"  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Re: correlated delete with "in" and "left outer join"  (Michael Chaney <mdchaney@michaelchaney.com>)
Список pgsql-general
I'm using postgresl 7.3.2 and have a query that executes very slowly.

There are 2 tables: Item and LogEvent.  ItemID (an int4) is the primary key
of Item, and is also a field in LogEvent.  Some ItemIDs in LogEvent do not
correspond to ItemIDs in Item, and periodically we need to purge the
non-matching ItemIDs from LogEvent.

The query is:

delete from LogEvent where EventType != 'i' and ItemID in
(select distinct e.ItemID from LogEvent e left outer join Item i
on e.ItemID = i.ItemID where e.EventType != 'i' and i.ItemID is null);

I understand that using "in" is not very efficient.

Is there some other way to write this query without the "in"?





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

Предыдущее
От: Karam Chand
Дата:
Сообщение: Re: Index Information
Следующее
От: Michael Glaesemann
Дата:
Сообщение: Re: correlated delete with "in" and "left outer join"