pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: Jainendra Kumar P <JAINK@infosys.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: How can I optimize this query
Date: Tue, 9 Sep 2003 22:17:37 -0500
Message-ID: <20030910031737.GA18726@wolff.to> (raw)
In-Reply-To: <284E845CC8F394409203F065D218205C044896@mysmsg03.ad.infosys.com>
References: <284E845CC8F394409203F065D218205C044896@mysmsg03.ad.infosys.com>

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.



view thread (2+ messages)

Message-ID: <20030910031737.GA18726@wolff.to>
Permalink:  ../20030910031737.GA18726@wolff.to/
Also on:    postgresql.org/message-id/20030910031737.GA18726@wolff.to

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: bruno@wolff.to, JAINK@infosys.com
  Subject: Re: How can I optimize this query
  In-Reply-To: <20030910031737.GA18726@wolff.to>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox