I would suggest writing the query like this:
select d.subscriber
from DEGREE d
where d.sub_type is null and
(d.subscriber like '91_9%' or
d.subscriber like '919%' or
not exists (select 1 from MCI where MCI.msisdn = d.subscriber)
);
Then create indexes on degree(sub_type, subscriber)
and MCI(msisdn)
.
EDIT:
The index on degree
should cause the following to happen. Instead of a full table scan on DEGREE
, the query will do an index scan on the index. I'm not sure if Oracle is smart enough to use the index for like
conditions connected by or
, but at least this is a covering index for the query.
The index on MCI
should then result in a simple index lookup.
So, with these two indexes, only index operations will be needed to satisfy the query. That should have a significant impact on performance.