Create Table T1 as select * from EMP;
Insert into T1 select * from T1;
Create index I _empno on T1 (empno );
Create index I _deptno on T1 (deptno );
@? \ RDBMS \ admin \ utlxplan
SQL> explain Plan for alter index I _empno rebuild;
Explained.
SQL> select * from table (dbms_xplan.display );
Plan_table_output
Bytes ---------------------------------------------------------------------------------------------------
Bytes ---------------------------------------------------------------------------------------------------
Plan hash value: 1909342220
----------------------------------------------------------------------------------
| ID | operation | Name | rows | bytes | cost (% CPU) | time |
----------------------------------------------------------------------------------
| 0 | alter index statement | 991k | 12m | 3302 (1) | 00:00:40 |
| 1 | index build non unique | I _empno |
| 2 | sort create index | 991k | 12m |
| 3 | index fast full scan | I _empno |
----------------------------------------------------------------------------------
10 rows have been selected.
SQL> explain Plan for alter index I _empno rebuild online;
Explained.
SQL> select * from table (dbms_xplan.display );
Plan_table_output
Bytes -----------------------------------------------------------------------------------------------------
Bytes ---------------------------------------------------------------------------------------------------
Plan hash value: 1499455000
----------------------------------------------------------------------------------
| ID | operation | Name | rows | bytes | cost (% CPU) | time |
----------------------------------------------------------------------------------
| 0 | alter index statement | 991k | 12m | 3302 (1) | 00:00:40 |
| 1 | index build non unique | I _empno |
| 2 | sort create index | 991k | 12m |
| 3 | table access full | T1 | 991k | 12m | 3302 (1) | 00:00:40 |
----------------------------------------------------------------------------------
10 rows have been selected.
It can be seen that rebuild and rebuild online scan methods are different, but sort will occur
An error is reported during rebuild online.
ORA-08120: need to create SYS. ind_online $ table in order to (re) Build Index
The solution is to run catcio. SQL to create the SYS. ind_online $ table.
In addition to different scanning methods, rebuild blocks DML statements while rebuild online does not.
The system generates a sys. in the IOT-type temporary system log table of ind_online $, all index changes during rebuild online are recorded in this table. After the new index is created, maintain the records of the table to the new index, drop the old index, and rebuild online is complete.
Their main difference lies in the difference between blocking DML operations and scanning data. Because DML operations are blocked to maintain the index itself during rebuild, it is more appropriate to use rebuild online in OLTP systems with frequent DML operations.
Reference http://www.bitscn.com/pdb/oracle/200701/88705.html