From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
---|---|
To: | Jainendra Kumar P <JAINK(at)infosys(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: How can I optimize this query |
Date: | 2003-09-10 03:17:37 |
Message-ID: | 20030910031737.GA18726@wolff.to |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Tue, Sep 09, 2003 at 13:39:10 +0530,
Jainendra Kumar P <JAINK(at)infosys(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Sydney-Smith | 2003-09-10 12:43:25 | how to vacum |
Previous Message | Jan Wieck | 2003-09-10 01:56:31 | Re: [HACKERS] plpgsql doesn't coerce boolean expressions to boolean |