I create an index on (SWcode,cdcardno)
and I run this query :
SELECT cd.*
FROM KS cd
where cd.cdcardno in ('6219862012953805')
ORDER BY cd.ROWID
and oracle use index skip scan and it is true . but when I run this query :
SELECT cd.*
FROM KS cd
where cd.cdcardno in ('6219861009150391','6219862012953805')
ORDER BY cd.ROWID
oracle use Full scan. I cant understand why.
Sometimes Oracle flaps between two exec plans, when one of them is bad and the other one is even worse. Create an index where
cdcardno
is on 1st position in the list. Or just flip order of columns in the current index.