|
|
Oracle is CBO is based on statistics to make judgement. I think up to 60% ~ 80% SQL is working fine, but still have room to improve by human expert. Have you really test the difference of your SQL with Hints and without Hints. I found some people always make mistake to test SQL speed. Use your SQL as an example :
select /*+ use_nl(a b) */ b.subscrbid,acctitmid,sum(fee)
from tab_fee a,tab_subscrb b
where telno=svcnum and part=:lvPart1
group by b.subscrbid,acctitmid;
You force an Nested Loop to the SQL and you may test it in SQL*Plus, as most people will not write a complete testing PL/SQL program to fetch all records from the SQL and not welling to wait thousands of records return from the SQL, So, most of time people may check/feel how soon the SQL will return records and believe this Nested Loop is better performance, but don't you know sometimes the Elapsed Time to fetch all records from a Nested Loop may much slower than a Sort Merge operation. Sort Merge operation response slow but may run very fast after sorting to catch up with Nested Loop afterward. |
|