SQL Performance (MOSC)

MOSC Banner

SQL Tuning – how to avoid the use of to_date() in a predicate that compares dates

edited May 23, 2013 5:42AM in SQL Performance (MOSC) 9 commentsAnswered ✓
Hello,

Could you help me to tune the following query?

select mes as param,  orden, count(orden) as total

from inp_003_t_hits a, inp_002_c_modulos b

where a.id_modulo = b.id_modulo and (fecha >= to_date('23/05/2012', 'DD/MM/YYYY'))

and (fecha <= to_date('30/06/2012', 'DD/MM/YYYY'))

group by mes, orden

order by mes

 

inp_003_t_hits table has the following structure:

 

CREATE TABLE INP_003_T_HITS

(

  ID         INTEGER,  

 ID_MODULO  INTEGER,   

  FECHA      DATE,      

  SEMANA     INTEGER,   

  DIA        INTEGER,   

  HORA       INTEGER,

  MES        INTEGER

)

 

The field FECHA has an index but because of to_date('23/05/2012', 'DD/MM/YYYY')

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center