sql - Oracle Index not being used when joining to another table -
sql - Oracle Index not being used when joining to another table -
i have next sql beingness run on oracle 10g database:
select /*+ all_rows */ to_number(cv.old_value) cv_id, to_number(job.old_value) job_id amendments, amnddets cv, amnddets job amendments.table_name = 'timesheet_layer' , amendments.dml_type = 'd' , cv.amnd_id = amendments.amnd_id , cv.column_name = 'cv_id' , job.amnd_id = amendments.amnd_id , job.column_name = 'job_id';
there next indexes 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 tried using ansi joins (the below sql) not utilize indexes either, placing upper()
around table_name
, dml_type
has no affect.
the above query taking approximately 30 - 40 secs retrieve around 2500 rows.
i looked @ explain plan , can't see index on amendments
table_name
, dml_type
beingness used.
below ansi explain plan for:
select /*+ all_rows */ to_number(cv.old_value) cv_id, to_number(job.old_value) job_id amendments bring together amnddets cv on cv.amnd_id = amendments.amnd_id , cv.column_name = 'cv_id' bring together amnddets job on job.amnd_id = amendments.amnd_id , job.column_name = 'job_id' upper(amendments.table_name) = 'timesheet_layer' , amendments.dml_type = 'd';
could 1 advise why table_name
, dml_type
, column_name
indexes aren't beingness used in above query?
if have run say:
create index amendments_dmp_type_upper on amendments upper(dmp_type);
then have created index on amendments(dmp_type)
without upper
function!
the right syntax is:
create index amendments_dmp_type_upper on amendments (upper(dmp_type));
perhaps surprisingly, statement works word "upper" treated table alias - works too:
create index amendments_dmp_type_upper on amendments foo(dmp_type);
sql oracle10g indexing
Comments
Post a Comment