Re: How can I optimize this query

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: How can I optimize this query
Дата
Msg-id 20030910031737.GA18726@wolff.to
обсуждение исходный текст
Ответ на How can I optimize this query  ("Jainendra Kumar P" <JAINK@infosys.com>)
Список pgsql-sql
On Tue, Sep 09, 2003 at 13:39:10 +0530, Jainendra Kumar P <JAINK@infosys.com> wrote:
> I have the following query
> 
> UPDATE accumulator1 SET accumulator1.status = "User Excluded"
> WHERE accumulator1.name NOT IN
> (SELECT DISTINCT accumulator1.name
>  FROM accumulator1, diaaffectedstmts
>  WHERE diaaffectedstmts.stmt like '*'+ accumulator1.name +'*' and
> diaaffectedstmts.xref_type <>  
>  "D");
> 
> How can I optimize this query?

It will probably work better in 7.4. But for now you might try replacing
NOT IN with NOT EXISTS. As long as accumulator1.name isn't going to be
NULL you should be able to rewrite the subselect to find rows where
name in the subselect matches name in the outer select.


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

Предыдущее
От: Jan Wieck
Дата:
Сообщение: Re: [HACKERS] plpgsql doesn't coerce boolean expressions to boolean
Следующее
От: "Richard Sydney-Smith"
Дата:
Сообщение: how to vacum