Differences between rebuild and rebuild online of Indexes

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.