How do I check index building status on Oracle 11?

WBAR picture WBAR · Sep 11, 2012 · Viewed 21k times · Source

I made terrible mistake in SQL index creation:

create index IDX_DATA_TABLE_CUSECO on DATA_TABLE (CUSTOMER_ID, SESSION_ID, CONTACT_ID)
  tablespace IDX_TABLESPACE LOCAL ;

As You can see I missed keyword "ONLINE" to create index without blocking PRODUCTION table with high usage with 600m+ records. Corrected SQL is:

create index IDX_DATA_TABLE_CUSECO on DATA_TABLE (CUSTOMER_ID, SESSION_ID, CONTACT_ID)
  tablespace IDX_TABLESPACE LOCAL ONLINE;

I was done it under PL/SQL Developer. When I was trying to stop it program stop responding and crashed.

Production system not working for 9 hours now and my boss wanna explode. :D

Is there any chance to see how many seconds/minutes/hours Oracle 11g left to process this index creation ? Or maybe is there any chance to see does Oracle still working on this request? (PL/SQL Developer crashed).

For haters: I know I should do this like mentioned here: (source)

CREATE INDEX cust_idx on customer(id) UNUSABLE LOCAL;
ALTER INDEX cust_idx REBUILD parallel 6 NOLOGGING ONLINE;

Answer

Justin Cave picture Justin Cave · Sep 11, 2012

You should be able to view the progress of the operation in V$SESSION_LONGOPS

SELECT sid, 
       serial#, 
       target, 
       target_desc, 
       sofar, 
       totalwork, 
       start_time, 
       time_remaining, 
       elapsed_seconds
  FROM v$session_longops
 WHERE time_remaining > 0

Of course, in a production system, I probably would have killed the session hours ago rather than letting the DDL operation continue to prevent users from accessing the application.