Oracle Database - Why you have still a lot of redo and archive ? The Index side effect

Oracle Database - Why you have still a lot of redo and archive ? The Index side effect

1 - About
You use the direct path insert and set the logging mode as NOLOGGING but you have still a lot of redo log generated.

Why ?

The answer is that you have an index on the table, and the index cannot just be appended to, they just be merged into. Since you need to merge data into them, you need redo in order to recover from instance failure. If your system crashed in the middle of the index operations, you would end up with a corrupt index structure. Hence, redo is generated for the index operations.

2 - Articles Related
Oracle Database - How can we load a large number of rows into an indexed existing table ?
Oracle Database - Redo Log (Log Files)
Oracle Database - Redo Size statistics
3 - Indexes are expensive complex data structure
Oracle Database - Indexes are complex data structure, so maintaining them can be expensive.

gerardnico@orcl> SELECT log_mode FROM v$database;

LOG_MODE
------------
ARCHIVELOG
The database is in Oracle Database - ARCHIVELOG mode.

3.1 - Without Index

gerardnico@orcl>SET autotrace ON statistics;
gerardnico@orcl>INSERT INTO big_table SELECT * FROM all_objects;

66651 rows created.


Statistics
----------------------------------------------------------
       6062  recursive calls
       9053  db block gets
     189602  consistent gets
          1  physical reads
    7533724  redo size
        901  bytes sent via SQL*Net TO client
        952  bytes received via SQL*Net FROM client
          4  SQL*Net roundtrips TO/FROM client
       1542  sorts (memory)
          0  sorts (disk)
      66651  rows processed
The data of the table generate 7,5MB of redo log.

3.2 - With the index

gerardnico@orcl>SET autotrace ON statistics;
gerardnico@orcl>CREATE INDEX big_table_idx ON big_table(owner,object_type,object_name);

INDEX created.

gerardnico@orcl>INSERT INTO big_table SELECT * FROM all_objects;

66652 rows created.


Statistics
----------------------------------------------------------
       6163  recursive calls
     174495  db block gets
     192120  consistent gets
        462  physical reads
   33037788  redo size
        906  bytes sent via SQL*Net TO client
        952  bytes received via SQL*Net FROM client
          4  SQL*Net roundtrips TO/FROM client
       1542  sorts (memory)
          0  sorts (disk)
      66652  rows processed



With the index, 33MB of redo are generated. 23MB only for the index !

Comments

Popular posts from this blog

Query for Tablespace usage with Autoextend

How to configure multiple Oracle listeners

sheel script - automatic tablespace addition in oracle 11g