Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 

 

 

Oracle Query Optimization

Oracle Database Tips by Donald Burleson

Question:

I would like to execute my query faster: can you please help me? The query works but it can get slow with different values... 

select distinct (tb1.SupporterID), tb1.lotteryNumber, tb1.DrawNumber,tb1.PrizeDrawID, tb1.prizeValue, tb1.winningTicket, tb1.title, tb1.initials, tb1.surname, tb1.address1,tb1.address2,tb1.address3,tb1.address4,
tb1.supporterNumber, tb1.prizeName from (select distinct pw1.SupporterID, pw1.PrizeWinID,Lpt.lotteryNumber, pw1.DrawNumber, pw1.PrizeDrawID, pd.prizeValue, pw1.winningTicket, pw1.title, pw1.initials, pw1.surname,pw1.address1,pw1.address2,pw1.address3,
pw1.address4, s.supporterNumber,p.prizeName from prize_win pw1inner join ( select pt.purchasedTicketID,L.lotteryNumber from purchased_Ticket pt inner join lottery L on  pt.lotteryID = L.lotteryID where L.lotteryNumber between 215 and 230) Lpt on pw1.PurchasedTicketID =Lpt.purchasedTicketID inner join prize_draw pd on pw1.PrizeDrawID =pd.PrizeDrawID inner join supporter s on pw1.SupporterID = s.SupporterID inner join prize p on pw1.PrizeDrawID = p.PrizeDrawID) tb1 inner
join (select pw1.SupporterID, pw1.PrizeWinID from prize_win  pw1 inner join (select pt.purchasedTicketID from purchased_Ticket pt inner join lottery L on pt.lotteryID = L.lotteryID where L.lotteryNumber between 215 and 230) Lpt on pw1.PurchasedTicketID = Lpt.purchasedTicketID ) tb2 on tb1.SupporterID = tb2.SupporterID where tb1.PrizeWinID <> tb2.PrizeWinID order by tb1.SupporterID asc;

Thanks.

This question posed on 10 January 2006

Answer:

Usually when the response time changes based on the values this indicates data skew. In other words, you put in "where x=10" you get back 5 values, "where x=5" gives back 3000. Oracle assumes that data is equally distributed around indexed values. If the data is not equally distributed about an index it is skewed. In order to help the optimizer with skewed data you need to use histograms. Histograms are created using the ANALYZE command or through options in the DBMS_STATS gather procedures.


 


 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.