oracle sql tuning examples
1.
there is one sql as follows :
select /*+index(create_time) */ * from h where h.result='F' and h.code<>'DO' and (h.code like :1 or h.code like :2 or h.code like :3) and h.create_time>:4 and h.create_time<:5
it has index on column ‘create_time’, :1, :2 and :3 can be %A,A% or %A%.
DBA told us that this is top sql, hence we need to optimize it.
My analysis are :
- it is useless that we create index on column 'code' since its value could be %A
- result only can be 'S' or 'F', but the 'S' occupy most data in DB(about 99%)
- 'create_time' index is not good according to execute plan
Therefore, after removing hint and add index on column ‘result’, the efficient improved huge.
Written on April 16, 2016