Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Influence Optimzer to merge 'IN' subquery

Re: Influence Optimzer to merge 'IN' subquery

From: <pobox002_at_bebub.com>
Date: 10 Feb 2005 05:32:32 -0800
Message-ID: <1108042352.744134.134280@z14g2000cwz.googlegroups.com>


Matt wrote:
>
> What I would like to do is use the values returned from the subselect
> to retrict the rows in the very large table before the table access.

> If this is possible I will reduce the table block viists by 90%.
>
> Here is the query:
>
> select sum(tl_quantity)
> from
> ps_tl_payable_time where emplid ='006938'
> and
> trc in
> (
> select valuegroup from ps_tl_val_list_dtl
> where list_id ='F-130HOURS'
> and list_type = 2
> )
> and dur >=
> TO_DATE('2004-01-01','YYYY-MM-DD')
> and dur <=
> TO_DATE('2004-12-03','YYYY-MM-DD')
>

Does this help

select sum(tl_quantity)
from
 ps_tl_payable_time where emplid ='006938',    (
   select distinct valuegroup from ps_tl_val_list_dtl    where list_id ='F-130HOURS'
   and list_type = 2
   and rownum > 0
   ) x
where

   x.valuegroup = trc
and dur >=

   TO_DATE('2004-01-01','YYYY-MM-DD')
and dur <=

   TO_DATE('2004-12-03','YYYY-MM-DD') The rownum will force the in line view to be processed first as the psuedo column means it cannot be merged.

I have also heard that the /*+ leading */ hint can be used to specify the driving table, but I have not tried it. That would become

select /*+ leading (x) */ sum(tl_quantity) from
 ps_tl_payable_time where emplid ='006938',    (
   select distinct valuegroup from ps_tl_val_list_dtl    where list_id ='F-130HOURS'
   and list_type = 2
   ) x
where

   x.valuegroup = trc
and dur >=

   TO_DATE('2004-01-01','YYYY-MM-DD')
and dur <=

   TO_DATE('2004-12-03','YYYY-MM-DD') Probably both worth a try.

-- 
MJB
Received on Thu Feb 10 2005 - 07:32:32 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US