To_char a date field and keep waiting for the results

How often do we see wrong use of to_char on date fields and causing huge performance impact?

Just saw a query with date field in where condition with to_char conversion with compared to a date value in string. It was a billion rows table and a simple count of rows was taking 3 hours to complete. Simply removing to_char from the date field and putting to_date on the date string like to_date(‘01-Jan-2019’,’DD-Mon-YYYY’) eliminated all the conversions on billion rows and query returned rows in .89 Seconds.

#QueryTuning #OracleTuning

Leave a comment

Your email address will not be published. Required fields are marked *