?
Solved

Join optimization

Posted on 2000-03-06
2
Medium Priority
?
526 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

777 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