Re: How can I optimize this query - Mailing list pgsql-sql

From Bruno Wolff III
Subject Re: How can I optimize this query
Date
Msg-id 20030910031737.GA18726@wolff.to
Whole thread Raw
In response to How can I optimize this query  ("Jainendra Kumar P" <JAINK@infosys.com>)
List 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 by date:

Previous
From: Jan Wieck
Date:
Subject: Re: [HACKERS] plpgsql doesn't coerce boolean expressions to boolean
Next
From: "Richard Sydney-Smith"
Date:
Subject: how to vacum