Hi guys forgive me if i dont give enough information we dont normally have many problems with slow queries as our data does not usually get to a level that is effected by speed.
I have a query that does a search of a view with approx 30k records. I then use a connect by to find all the relevent records that apply to this scenerio and place the results into an oracle form.
I have hard coded an example ('ACT' and 6089) into this code, but usually the numbers/code will be a parameter thats passed in.
Individually the select itemcode,notes from v_allitems takes approx 0.1 seconds to run
and the IN statement takes approx 0.007 seconds to run.
Together they take over 6 seconds which is a little too slow. So i assume its the IN thats causing me the problem as i am returning over 100 records to search IN. Is there an alternate way other than IN that anyone can think of to achieve the desired result?
Thanks in advance
select ITEMCODE, notes from v_allitems
where ITEMCODE = ( 'ACT'||','||6089) OR ITEMCODE IN
(SELECT pcchildcode
||','
|| pcchild item
FROM afpc
CONNECT BY pcparent = prior pcchild
AND pcparentcode = prior pcchildcode START
WITH pcparent = 6089
AND pcparentcode = 'ACT'
UNION ALL
SELECT pcparentcode
||','
|| pcparent item
FROM afpc
CONNECT BY pcchild = prior pcparent
AND pcchildcode = prior pcparentcode START
WITH pcchild = 6089
AND pcchildcode = 'ACT'
)