Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 16th, 2011, 10:27 AM
SFDonovan's Avatar
SFDonovan SFDonovan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Location: Texas
Posts: 350 SFDonovan User rank is Lance Corporal (50 - 100 Reputation Level)SFDonovan User rank is Lance Corporal (50 - 100 Reputation Level)SFDonovan User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 3 Days 14 h 45 m 42 sec
Reputation Power: 6
Facebook
Inefficient VIEW

I have a view that gets used 3 times by another query and am being told that the view is inefficient.

Any reccomendations on how I could change this?

I noticed this view is getting the value of acad_prog three times.

Once from ps_acad_prog when finding the MAX of effdt, again from ps_acad_prog finding the MAX of effseq, and from ps_acad_prog when find the MAX of effdt from the ps_acad_plan_tbl.


PHP Code:
 SELECT a.emplid 
 
a.acad_career 
 
,r.effdt 
 
c.acad_plan 
 
d.descr 
 
a.institution 
 
a.acad_prog 
 
b.descr 
 
d.degree 
 
b.acad_group 
  FROM ps_acad_prog a 
  
ps_acad_prog_tbl b 
  
ps_acad_plan c 
  
ps_acad_plan_tbl d 
  
ps_ntsr_ref2_tbl r 
 WHERE a
.emplid c.emplid 
   
AND a.institution=b.institution 
   
AND a.institution=d.institution 
   
AND a.acad_career=b.acad_career 
   
AND a.acad_career=c.acad_career 
   
AND a.acad_prog=b.acad_prog 
   
AND a.acad_prog=d.acad_prog 
   
AND c.acad_plan=d.acad_plan 
   
AND a.effdt c.effdt 
   
AND a.effseq=c.effseq 
   
AND r.emplid=a.emplid 
   
AND r.acad_career=a.acad_career 
   
AND r.institution=a.institution 
   
AND a.effdt = ( 
 
SELECT MAX(prg.effdt
  
FROM ps_acad_prog prg 
 WHERE prg
.emplid a.emplid 
   
AND prg.acad_career a.acad_career 
   
AND prg.stdnt_car_nbr a.stdnt_car_nbr 
   
AND (prg.acad_prog BETWEEN '200' AND '309' 
    
OR prg.acad_prog '350' 
    
OR prg.acad_prog BETWEEN '401' AND '457'
   AND 
prg.effdt <= SYSDATE 
   AND 
a.effseq = ( 
 
SELECT MAX(prg1.effseq
  
FROM ps_acad_prog prg1 
 WHERE prg1
.emplid a.emplid 
   
AND prg1.acad_career a.acad_career 
   
AND prg1.stdnt_car_nbr a.stdnt_car_nbr 
   
AND Prg1.effdt a.effdt 
   
AND (prg1.acad_prog BETWEEN '200' AND '309' 
    
OR prg1.acad_prog '350' 
    
OR prg1.acad_prog BETWEEN '401' AND '457')) 
   AND 
a.acad_career = ( 
 
SELECT MIN(ac.acad_career
  
FROM ps_acad_prog ac 
 WHERE ac
.emplid a.emplid 
   
AND ac.institution a.institution
   AND 
b.effdt=( 
 
SELECT MAX(ed.effdt
  
FROM ps_acad_prog_tbl ed 
 WHERE ed
.acad_prog b.acad_prog 
   
AND ed.eff_status b.eff_status 
   
AND ed.institution b.institution 
   
AND ed.effdt <= a.effdt
   AND 
d.effdt = ( 
 
SELECT MAX(ed1.effdt
  
FROM ps_acad_plan_tbl ed1 
 WHERE ed1
.acad_plan d.acad_plan 
   
AND ed1.eff_status d.eff_status 
   
AND ed1.acad_prog=d.acad_prog 
   
AND ed1.institution d.institution 
   
AND ed1.effdt <= a.effdt
   AND 
b.eff_status 'A' 
   
AND b.eff_status d.eff_status 
   
AND (a.acad_prog BETWEEN '200' AND '309' 
    
OR a.acad_prog '350' 
    
OR a.acad_prog BETWEEN '401' AND '457'
   AND 
c.acad_plan NOT LIKE '%MNU' 
   
AND a.prog_status <> 'CM' 

Reply With Quote
  #2  
Old September 16th, 2011, 10:53 AM
shammat shammat is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Oct 2003
Location: Germany
Posts: 2,685 shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 3 Days 19 h 53 m 13 sec
Reputation Power: 284
First step in analyzing performance problems: look at the execution plan.

First step when posting here: post the table definitions including all defined indexes together with the query and the execution plan.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Inefficient VIEW

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap