sql - Oracle query taking a long time -
a condensed version of query below (because of how many variables there are), when run sub-query runs in 2 seconds, yet when surround it, takes upwards of half hour. have checked column names - twice. why happening? , can fix it?
select amount, comments, firstname, lastname, termname, adjustmenttype, void_indicator ( select c.amount amount, c.comments comments, p.firstname firstname, p.lastname lastname, e.termname termname, c.adjustmenttype adjustmenttype, b.voidindicator void_indicator chargesdtl c, chargeshdr b, peoplehdl p, termmaster e ( b.studentnumber=p.studentnumber , c.termid = e.term_id , b.adjustmentnumber=c.adjustmentnumber , p.personid=b.personid , b.locationcode='12' ) union select c.amount amount, c.comments comments, p1.firstname firstname, p1.lastname lastname, e.termname termname, c.adjustmenttype adjustmenttype, b.voidindicator void_indicator chargesdtl c, chargeshdr b, peoplehdl p1, termmaster e ( b.studentnumber=p.studentnumber , c.termid = e.term_id , b.adjustmentnumber=c.adjustmentnumber , p1.personid = b.personid , b.locationcode='13' ) order adjustmenttype )
as mentioned in comment question. query can condensed down 1 single query set of join statements. union , derived table unnecessary.
select c.amount, c.comments, p.firstname, p.lastname, e.termname, c.adjustmenttype, b.voidindicator chargesdtl c inner join termmaster e on e.termid = c.term_id inner join chargeshdr b on b.adjustmentnumber = c.adjustmentnumber inner join peoplehdl p on p.personid = b.personid , p.studentnumber = b.studentnumber (b.locationcode = '12' or b.locationcode = '13') order c.adjustmenttype
Comments
Post a Comment