SQL Tuning – how to avoid the use of to_date() in a predicate that compares dates
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')