I have a query on a junction table that looks like this:
The role is to know if a given node is present anywhere in the junctions. This is a generic system that MAY use the eleven columns but would, most of the time, use between 2 and 4 columns. Actually, my index is made of the 11 keys so my explain plan is
From what I understand, COUNT STOPKEY should make the query stop on the first encounter but according to the detail provided in Enterprise Manager, 95,83% of runs extract all lines! This gives me a request that takes, in average, near 40 seconds to run on a 1million lines table! Half and half between buffer gets and disk reads.
Is there something I don't understand about COUNT STOPKEY? Is there anything I could do to optimize this?
Any help will be gladly appreciated!
SQL:
SELECT 1
FROM MyTable
WHERE (k1 = :A1 OR k2 = :A2 OR k3 = :A3 OR k4 = :A4 OR k5 = :A5 OR k6 = :A6 OR k7 = :A7 OR k8 = :A8 OR k9 = :A9 OR k10 = :A10 OR k11 = :A11) AND ROWNUM <= 1
The role is to know if a given node is present anywhere in the junctions. This is a generic system that MAY use the eleven columns but would, most of the time, use between 2 and 4 columns. Actually, my index is made of the 11 keys so my explain plan is
Code:
SELECT STATEMENT, GOAL = ALL_ROWS Cost=1 Cardinality=1 Bytes=50
COUNT STOPKEY
INDEX FULL SCAN Owner object=MYOWNER OBJECT NAME=MYT_PRIMARY Cost=1 Cardinality=1 Bytes=50
From what I understand, COUNT STOPKEY should make the query stop on the first encounter but according to the detail provided in Enterprise Manager, 95,83% of runs extract all lines! This gives me a request that takes, in average, near 40 seconds to run on a 1million lines table! Half and half between buffer gets and disk reads.
Is there something I don't understand about COUNT STOPKEY? Is there anything I could do to optimize this?
Any help will be gladly appreciated!