Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Index is not used...

HokinsMay 30 2012 — edited Jul 9 2012
Hi, I have a DB with 20 M records. I am using a query to search records but it is not using index. Query is as follows:-


select *
from DOCUMENT_IN documentin0_
inner join ORGANISATION_SYN organisati1_ on documentin0_.ORIGINATING_SECTION_ID=organisati1_.ID
inner join FILE_RECORD filerecord2_ on documentin0_.FILE_RECORD_ID=filerecord2_.ID
inner join doc_security_lookup documentse3_ on documentin0_.ID=documentse3_.DOCUMENT_ID and ( documentse3_.document_type like 'In')
inner join DOCUMENT_IN_FILE documentin4_ on documentin0_.ID=documentin4_.DOCUMENT_IN_ID
where documentse3_.APPOINTMENT_ID=:1
and documentin0_.IS_DELETE='No'
and (:2 is null or lower(documentin0_.SUBJECT) like :2)
and (:3 is null or documentin0_.DOCUMENT_ID like :3 )
and (:4 is null or documentin0_.RECEIVE_DATE>=:4)
and (:5 is null or documentin0_.RECEIVE_DATE<:5)


I have defined index on document_ID. When i use ":3 is null or documentin0_.DOCUMENT_ID like :3" then it is not using the Index and goes for full table scan. But when i change it to "documentin0_.DOCUMENT_ID like :3" then it uses the Index. I am using above pattern to avoid hard parsing.

Thanks for ur relpy.

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Aug 6 2012
Added on May 30 2012
4 comments
396 views