Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Optimizing MINUS query

582648Jul 4 2007 — edited Jul 4 2007
Hi All,

Please help me in optimizing my MINUS query, I had created a web portal using pl/sql to view the difference between two data loads into a table each data load has its own version number.
for example:
consider table xx
Ver id opt Wcc code st_dt end_dt rate
253 2 xx NBK 0 8/1/2002 7/31/2005 0.02
253 2 xx NBK 0 8/1/2005 3/31/2006 0.01
258 2 yy BKN 0 4/1/2006 12/31/209 0.01
258 2 yy BKN 1 8/1/2002 7/31/2005 0.02

If the table is containing data in thousands my web portal is taking at least 5min to display the difference of the data present for version 253 and 258.

the MINUS query i have written in my code is

select
tab1.id, tab1.opt, tab1.Wcc, tab1.code,tab1.st_dt, tab1.end_dt, tab1.rate
from xx tab1,
(SELECT id,opt,Wcc,code,st_dt,rate FROM xx WHERE ver = 253
minus SELECT id,opt,Wcc,code,st_dt,rate FROM xx WHERE ver = 258 ) tab2
where tab1.id||tab1.opt||tab1.wcc||tab1.code||tab1.st_dt||tab1.rate=tab2.id||tab2.opt||tab2.Wcc||tab2.code||tab2.st_dt||tab2.rate
and tab1.ver in (258,253);


how can i optimize my query so that i can view the difference in min time through the web portal??
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 1 2007
Added on Jul 4 2007
6 comments
598 views