Skip to Main Content
  • Questions
  • ORA-01502 with hardcoded index hints

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Michael.

Asked: February 19, 2018 - 3:04 pm UTC

Last updated: February 23, 2018 - 12:33 am UTC

Version: 11.2.0.4

Viewed 1000+ times

You Asked

We have EBS 12.1.3, which has several indexes, that we disable for bulk loading at night and rebuild them once done.
While they are disabled some queries get ORA-01502 because of hard coded index hint on these unusable indexes, although we have skip_unusable_indexes=true. We are unable to remove the hard coded hint, is there something else to do to prevent the error and keep the indexes in unusable state?

and Connor said...

Unfortunately I don't have any real good news for you.

The "correct" answer is such hints should not be specified, but of course, that is of not much use to you, because its our own product you're using.

I'm hesitant to recommend anything like dbms_advanced_rewrite or sql translation framework as a way of forcing sql rewrites on the fly, because it would probably be in violation of the support for EBS.

All I can suggest is have a chat with Support for options.

Sorry.


Rating

  (4 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

I thought

A reader, February 20, 2018 - 5:27 am UTC

Am I missing something? I thought that hint are ignored if they are not relevant or erroneous;

Select /*+ dummy6*/ is ignored no?
Connor McDonald
February 22, 2018 - 1:42 am UTC

If you use a hint to force the use of an index that is unusable, you will get the "index is unsuable" error *even if* the initialization parameter 'skip_unusable_indexes' is true.

on ORA-01502 error

Rajeshwaran Jeyabal, February 20, 2018 - 5:59 am UTC

Am I missing something? I thought that hint are ignored if they are not relevant or erroneous;
ORA-01502 error will be raised during data loads while the index marked as unusable status that supports constraints/keys.
Something like this.
demo@ORA11G> create table t(x int,y varchar2(30),z date,object_id int ,
  2     constraint t_pk primary key(x) )
  3  partition by hash(object_id)
  4  ( partition p1, partition p2 );

Table created.

demo@ORA11G>
demo@ORA11G> alter index t_pk unusable;

Index altered.

demo@ORA11G>
demo@ORA11G> insert into t(x,y,z,object_id)
  2  select id,object_name,created,id
  3  from big_table;
insert into t(x,y,z,object_id)
*
ERROR at line 1:
ORA-01502: index 'DEMO.T_PK' or partition of such index is in unusable state


rather than setting the index unusable and doing the data loads, you could disable the constraint, do data load and later enable the constraint.
demo@ORA11G> alter index t_pk rebuild;

Index altered.

demo@ORA11G> alter table t disable constraint t_pk;

Table altered.

demo@ORA11G> insert into t(x,y,z,object_id)
  2  select id,object_name,created,id
  3  from big_table;

1000000 rows created.

demo@ORA11G> alter table t enable constraint t_pk;

Table altered.

demo@ORA11G>

BTW, do we really need to set the index to unusable state during data loads? why not just do a direct path loads? - since direct path loads use the blocks above the high water mark, it builds the index for the newly loaded data and nicely merge them with the existing index as part of the data loads.

on ORA-01502 error - documentation link

Rajeshwaran Jeyabal, February 20, 2018 - 6:01 am UTC

Sorry to miss this link in the above response.

https://docs.oracle.com/cd/E11882_01/server.112/e17766/e1500.htm#sthref843

ORA-01502: index 'string.string' or partition of such index is in unusable state

Cause: An attempt has been made to access an index or index partition that has been marked unusable by a direct load or by a DDL operation

Action: DROP the specified index, or REBUILD the specified index, or REBUILD the unusable index partition

Some workaround

Michael Sharfman, February 22, 2018 - 6:56 am UTC

We were able to overcome the error with setting an index as invisible as well. Just FYI...
Thanks for your effort!
Connor McDonald
February 23, 2018 - 12:33 am UTC

Hey - what an awesome resolution!

I'll blog about this (with due acknowledgement of course).

Thanks for sharing.

More to Explore

SQL

The Oracle documentation contains a complete SQL reference.