I have the following sql being run on an Oracle 10g database:
select /*+ ALL_ROWS */
to_number(cv.old_value) as cv_id,
to_number(job.old_value) as job_id
from amendments,
amnddets cv,
amnddets job
where amendments.table_name = 'TIMESHEET_LAYER'
and amendments.dml_type = 'D'
and cv.amnd_id = amendments.amnd_id
and cv.column_name = 'CV_ID'
and job.amnd_id = amendments.amnd_id
and job.column_name = 'JOB_ID';
There are the following indexes that have been created:
create index amendments_dmp_type_upper on amendments upper(dmp_type);
create index amendments_table_name_upper on amendments upper(table_name);
create index amendments_pk on amendments (amnd_id);
create index amended_column_name_idx on amnddets (column_name);
create index amnddets_amnd_id_idx on amnddets (amnd_id);
I have also tried using ANSI joins (the below sql) but this does not use the indexes either, placing upper() around the table_name and dml_type also has no affect.
The above query is taking approximately 30 – 40 secs to retrieve around 2500 rows.
I looked at the explain plan and can’t see that the index on amendments for table_name and dml_type are being used.

Below is the ANSI explain plan for:
select /*+ ALL_ROWS */
to_number(cv.old_value) as cv_id,
to_number(job.old_value) as job_id
from amendments
JOIN amnddets cv on cv.amnd_id = amendments.amnd_id and cv.column_name = 'CV_ID'
JOIN amnddets job on job.amnd_id = amendments.amnd_id and job.column_name = 'JOB_ID'
where upper(amendments.table_name) = 'TIMESHEET_LAYER'
and amendments.dml_type = 'D';

Could any one advise why the table_name, dml_type and column_name indexes aren’t being used in the above query?
If you have actually run this as you say:
then what you have actually created is an index on
amendments(dmp_type)without theupperfunction!The correct syntax is:
Perhaps surprisingly, your statement works but the word “upper” is treated as a table alias – this works too: