Search code examples
oracle-databaseperformancedateoracle12c

Re-write to_char function


When I use to_char function, It's know as internal_function in EP, and Index can't work in this column. Are there any way to re-write it? I don't want to create a function based index

This is my predicates code.

TO_CHAR(createdate,'dd-mm-yyyy') = TO_CHAR(systimestamp,'dd-mm-yyyy')

Many thanks.


Solution

  • Yes, this is exactly the reason we must use purely the date column on one side and a trunc(sysdate) like expression on the other instead of TO_CHAR while doing date comparisions.

    where  createdate  >= trunc(sysdate) 
       and createdate  <  trunc(sysdate) + 1