Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Join optimization

Posted on 2000-03-06
2
Medium Priority
?
528 Views
Last Modified: 2012-06-27
How could I optimize this select?
select narusenigvd.narusenikod
from vlak, trasa, narusenigvd
where
vlak.dojezd >= to_date('01.03.2000 00:00','DD.MM.YYYY HH24:MI') and
vlak.denjizdy <= to_date('02.03.2000 00:00','DD.MM.YYYY HH24:MI') and
vlak.idvlak = trasa.idvlak and
trasa.idtrasa = narusenigvd.idtrasa;

Every attribute have his own index.

Here is plan of the select:
SELECT STATEMENT   Cost: 7152                                                  
  HASH JOIN                                                                    
    TABLE ACCESS FULL NARUSENIGVD                                              
    NESTED LOOPS                                                                
      TABLE ACCESS FULL VLAK                                                    
      TABLE ACCESS BY INDEX ROWID TRASA                                        
        INDEX RANGE SCAN TRASA_VLAK NON-UNIQUE                                  

Why there is full access to tables 'natusenigvd' and 'vlak'?
0
Comment
Question by:knill
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
rkogelhe earned 300 total points
ID: 2586922
Knill,

Sometimes the optimizer is just ornery and one has to ritually sacrifice old oracle cds to get it to do what you want.

I suspect in this case that the vlak scans are because oracle has decided that the date ranges -might- hit >20% of the rows regardless. From a human perspective it sure looks like we're only talking about a day here, but the oo thinks it might have to look at half the data.

One suggestion is to create histograms on the date columns, another is to add criteria to the date conditions to limit to "between" conditions. You probably know if

vlak.dojezd >= to_date('01.03.2000 00:00','DD.MM.YYYY HH24:MI') and
vlak.dojezd <= to_date('02.03.2000 00:00','DD.MM.YYYY HH24:MI') and
vlak.denjizdy >= to_date('01.03.2000 00:00','DD.MM.YYYY HH24:MI') and
vlak.denjizdy <= to_date('02.03.2000 00:00','DD.MM.YYYY HH24:MI')  

is also a valid condition...

The narusenigvd problem is probably caused by the full on vlak. It probably suspects it will need all the values in the narusenigvd table, in which case a hash is faster. It may also think that the table is relatively small.

If this doesn't help, consider posting the main optimizer statistics for the tables and join columns.

Regards,

Ryan
0
 

Author Comment

by:knill
ID: 2586946
I added the conditions and cost is naw 201.
Thank you.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question