I have a SQL query that I believe is causing an implicit date conversion in my where clause. The query is:
select to_char(min(begin_date),'yyyy-MM-dd') from pay_table where TO_TIMESTAMP ('2008-07-01', 'YYYY-MM-DD HH24:MI:SS.FF') <= pay_date and TO_TIMESTAMP ('2009-6-30', 'YYYY-MM-DD HH24:MI:SS.FF') >= end_date
This is a "canned" vendor application, so the SQL cannot be changed. I have been asked to look into creating an index that will speed this up. I tried creating a function-based index on the date columns, but got the "ORA-01743: only pure functions can be indexed" error. The index I tried to create was:
CREATE INDEX PAY_TABLE_FBI ON PAY_TABLE
(TO_TIMESTAMP (PAY_DATE, 'YYYY-MM-DD HH24:MI:SS.FF'), TO_TIMESTAMP (END_DATE, 'YYYY-MM-DD HH24:MI:SS.FF'), BEGIN_DATE);
I've been reading up on only using functions that are deterministic, but it would seem that this would return the same value for the inputs. I believe I'm okay with regards to nls date parameters.
Can anyone suggest other reading I can do? Or, point out the obvious if I'm missing it ;-)
Thanks much!
select to_char(min(begin_date),'yyyy-MM-dd') from pay_table where TO_TIMESTAMP ('2008-07-01', 'YYYY-MM-DD HH24:MI:SS.FF') <= pay_date and TO_TIMESTAMP ('2009-6-30', 'YYYY-MM-DD HH24:MI:SS.FF') >= end_date
This is a "canned" vendor application, so the SQL cannot be changed. I have been asked to look into creating an index that will speed this up. I tried creating a function-based index on the date columns, but got the "ORA-01743: only pure functions can be indexed" error. The index I tried to create was:
CREATE INDEX PAY_TABLE_FBI ON PAY_TABLE
(TO_TIMESTAMP (PAY_DATE, 'YYYY-MM-DD HH24:MI:SS.FF'), TO_TIMESTAMP (END_DATE, 'YYYY-MM-DD HH24:MI:SS.FF'), BEGIN_DATE);
I've been reading up on only using functions that are deterministic, but it would seem that this would return the same value for the inputs. I believe I'm okay with regards to nls date parameters.
Can anyone suggest other reading I can do? Or, point out the obvious if I'm missing it ;-)
Thanks much!