Sunday, June 14, 2015

Oracle is using the to_char function degrading some of query performance?

Answer is   Yes.

1) It negates the use of an index on Column, if such exists
2) It causes dates to be sorted lexically instead of by actual date value
3) It causes to_char() to be run on every row


Instead of:

  to_char(T.mycol, 'YYYY-MM-DD') between '2015-01-20' and '2015-08-20'

Use:

T.mycol between TO_DATE('2009-08-20', 'YYYY-MM-DD') and TO_DATE('2009-08-20', 'YYYY-MM-DD')


Yasser

No comments:

Post a Comment