to_date and to_char performance
Hello,
I have a client with the following slow query that takes
9 seconds:
select * from client.client
where to_char(create_date,'J') = to_char(sysdat-1,'J');
Assume create_date is type date. We can easly speed this up:
select * from client.client
where ( create_date >= to_date(sysdate)
and create_date < to_date(sysdate));
This takes 0.07 seconds. The only catch is that the sessions
nls_date_format MUST be in a 'DD-MON-YYYY' format, or the query
will give false results. But that's no problems because we change
the ora.init file to specify nls_date_format globally.
My client is concerned that if ( big IF ), the nls_date_format
is changed for a session the query will fail and they are concerned.
Unlikely, but possible since we are using PHP with persistent
connetions and a previous query could change the nls_date_format
for that particular session.
Is there any solutions to this? Can we disable the nls_date_format
from begin altered at the session level?
Thanks
Jay