Hi Jorge
If I take a look at the explain plan for your query:
SELECT not_log.nlh_start, not_log.nlh_status, not_log.id FROM not_log WHERE not_log.cntxt_obj = N'cr:1689088'
ORDER BY not_log.nlh_start DESC NULLS LAST;
in my Environment I see that the index NOT_LOG_X2 gets used and so a performant query is executed.
when I change my session to case insensitive settings, using raghus suggestion (the same way how the SDM orcl_agents set their sesssion environment)
alter session set NLS_COMP=ANSI;
alter session set NLS_SORT=BINARY_CI;
the index is not used anymore, instead a full table scan is done (which is always bad), and therefore I have a slow execution, of course depending on the amount of records in the not_log table.
The DDL script of index NOT_LOG_X2 Looks like:
CREATE INDEX MDBADMIN.NOT_LOG_X2 ON MDBADMIN.NOT_LOG
(CNTXT_OBJ)
I created an analogue so called function based index which can be used by the DB in a case insensitive access situation
CREATE INDEX MDBADMIN.NOT_LOG_IDX_02_CI ON MDBADMIN.NOT_LOG
(NLSSORT("CNTXT_OBJ",'nls_sort=''BINARY_CI'''))
TABLESPACE YOUR_INDEX_TABLESPACE_NAME HERE;
after adding this index the query above uses the new index and runs fast again, even in a case insensitive access situation.
Give it a try , if you like, and let us know your results.
Hope that helps
Kind regards
.............Michael