This was a challenge from uni test.
The requierment was to solve It using hints.
I'm trying to complete a query where I want it to use nested loops and NO indices. For this, I wrote the query:
select /*+ USE_NL(fulltable) NO_INDEX(fulltable) */ sum(QUANTITY) summarized from
(select /*+ USE_NL(sz1, sz2, c1) NO_INDEX(sz1, sz2, c1) */ distinct *
from SZTABLE sz1
natural join SZTABLE2 sz2
natural join CTABLE c1
where city= 'Newark' and COLOR= 'red') fulltable;
However, upon explaining the query and writing it out, I get:
SELECT STATEMENT + +
SORT + AGGREGATE +
VIEW + +
HASH + UNIQUE +
NESTED LOOPS + +
NESTED LOOPS + +
HASH JOIN + +
JOIN FILTER + CREATE + :BF0000
TABLE ACCESS + FULL + CTABLE
VIEW + + VW_DTP_5C333E12
HASH + UNIQUE +
JOIN FILTER + USE + :BF0000
TABLE ACCESS + FULL + SZTABLE
INDEX + UNIQUE SCAN + SZO_SZKOD
TABLE ACCESS + BY INDEX ROWID + SZTABLE2
Apparently, the query still uses indices, even though I explicitly asked it not to. How can I fix this? Why is there still and index used for ROWID?
(The plan was written out by the snippet below.)
SELECT LPAD(' ', 2*(level-1))||operation||' + '||options||' + '||object_name terv
FROM plan_table
START WITH id = 0 AND statement_id = 'plan1'
CONNECT BY PRIOR id = parent_id AND statement_id = 'plan1'
ORDER SIBLINGS BY position;
Strange question but you can get all your index on tables involving into query and execute this:
Or rewrite query
Look at combination
Results are the same but CBO see expr and can't find it in index