Sunday, 20 November 2016

Oracle Index Pocket Reference



Consider EMP table :
UID VARCHAR2(25) PRIMARY KEY,
JOINING_DATE DATE,
ENAME VARCHAR2(100),
DESG VARCHAR2(50),
JOB_CODE VARCHAR2(50))

Index Type
Indexed Columns
Result
Query
Composite Index
uid,
joining_date
index works for both
columns
where uid='GANESH' and
joining_date between '01-jan-11' and '31-jan-11'


index works for uid
where uid='GANESH' and
trunc(joining_date) between '01-jan-11' and '31-jan-11'


Full Table scan
where upper(uid)='GANESH' and
joining_date between '01-jan-11' and '31-jan-11'


index works for
joining_date
where joining_date = '01-jan-11'


Full Table scan
where trunc(joining_date) = '01-jan-11'


index works for
joining_date
select /*+ index(Join_dt_I1) */  *
from emp 
where   joining_date between  '01-jan-11' and '31-jan-11'
Bit Map
Job_Code
Full Table scan
where   trunc(joining_date) between
 '01-jan-11' and '31-jan-11' and Job_Code='UUUIII23'


index works for
joining_date and r_code
where   joining_date between
 '01-jan-11' and '31-jan-11' and Job_Code='UUUIII23'

No comments:

Post a Comment