Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Optimizer
Hi could you please include the trace 10046 for that query (raw file)
without tkprof.
Thanks
Juan Carlos Reyes Pacheco
OCP
-------Original Message-------
From: FREEMANR_at_tusc.com
Date: 09/30/04 17:18:22
To: 'oracle-l_at_freelists.org '
Subject: Optimizer
I can do backup and recovery in my sleep.... I can create databases, and I am not a bad SQL tuning fellow I must say.. But, if there were to be an Oracle inqusition, I would have to confess that the optimizer still befuddles me sometimes. I have two tables: EMP and DEPT. EMP has 15,000 rows and DEPT has 1 row. No indexes. Real simple.
I have a simple SQL statement joining these tables:
select a.empid, a.ename, b.dname
from emp a, dept b
where a.deptno=b.deptno
and a.empid < 1000;
In playing with this statement, this is the execution path the optimizer takes:
Execution Plan
Statistics
If I do an ORDERED hint and reverse the join order, I get these results:
Execution Plan
Statistics
Note that the plan the optimizer chooses results in more consistent gets, than the plan using the ordered hint does. I would expect that for something this basic, the optimizer would "get it right" and come up with the better plan, which the later plan seems to be. Any thoughts on this? Did I miss something basic in my statistics gathering? I gathered stats for all columns, and did 100 buckets for the histograms.
I note that the cost for both plans is the same, so is there some tie breaking going on and if so, what are the rules for this tie breaking? Or...Is this just a "law of diminishing returns" thing, and the difference is so slight that Oracle could just go either way? I'm going to add more rows to both tables and see if that impacts the results....
Thoughts anyone?
RF
--
http://www.freelists.org/webpage/oracle-l
--
http://www.freelists.org/webpage/oracle-l
Received on Thu Sep 30 2004 - 16:32:46 CDT
![]() |
![]() |