pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedHow can I optimize this query
2+ messages / 2 participants
[nested] [flat]
* How can I optimize this query
@ 2003-09-09 08:09 Jainendra Kumar P <JAINK@infosys.com>
0 siblings, 1 reply; 2+ messages in thread
From: Jainendra Kumar P @ 2003-09-09 08:09 UTC (permalink / raw)
To: pgsql-sql
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?
Thanks
Jain
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: How can I optimize this query
@ 2003-09-10 03:17 Bruno Wolff III <bruno@wolff.to>
parent: Jainendra Kumar P <JAINK@infosys.com>
0 siblings, 0 replies; 2+ messages in thread
From: Bruno Wolff III @ 2003-09-10 03:17 UTC (permalink / raw)
To: Jainendra Kumar P <JAINK@infosys.com>; +Cc: 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.
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-09-10 03:17 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-09-09 08:09 How can I optimize this query Jainendra Kumar P <JAINK@infosys.com>
2003-09-10 03:17 ` Bruno Wolff III <bruno@wolff.to>
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