Total Pageviews

Thursday, 14 March 2013

Maximize the Data Up-Load Performance in Oracle



Use a combination of the following two features to maximize the speed of the insert statements:

  • Set table’s logging attribute to NOLOGGING.
  • Use direct path loading feature, such as the following:
                                i.            Insert /* APPEND */ on queries that use a subquery for determining which   records are inserted.
                              ii.            INSERT /*+ APEND_VALUES */ on queries that use a VALUES clause.
                            iii.            Create table ….As SELECT  
Below is the example to insert the data of table “test_backup” into test table with minimum redo generation:
1.First check the logging mode of the test table.
Select  table_name,logging from user_tables where table_name = 'Test';

2.If the table is in logging mode , alter it to nologging mode.

Alter table test nologging;

3. Now that NOLOGGING has been enabled, there should be a minimal amount of redo generated for direct path operations. The following example uses a direct path INSERT statement to load data into the table:

insert /*+APPEND */ into Test select * from test_backup;

How It Works

Direct path inserts have two performance advantages over regular insert statements:
  • If NOLOGGING is specified, then a minimal amount of redo is generated.
  • The buffer cache is bypassed and data is loaded directly into the datafiles. This can significantly improve the loading performance.

The NOLOGGING feature minimizes the generation of redo for direct path operations only. For direct path inserts, the NOLOGGING option can significantly increase the loading speed. One perception is that NOLOGGING eliminates redo generation for the table for all DML operations. That isn’t correct. The NOLOGGING feature never affects redo generation for regular INSERT, UPDATE, MERGE, and DELETE statements.

One downside to reducing redo generation is that you can’t recover the data created via NOLOGGING in the event a failure occurs after the data is loaded (and before you back up the table). If you can tolerate some risk of data loss, then use NOLOGGING but back up the table soon after the data is loaded. If your data is critical, then don’t use NOLOGGING. If your data can be easily re-created, then NOLOGGING is desirable when you’re trying to improve performance of large data loads.
What happens if you have a media failure after you’ve populated a table in NOLOGGING mode (and before you’ve made a backup of the table)? After a restore and recovery operation, it will appear that the table has been restored:

SQL> desc Test;
Name Null? Type
----------------------------------------- -------- ----------------------------
Test_ID NUMBER
NAME VARCHAR2(2000)

However, when executing a query that scans every block in the table, an error is thrown.

SQL> select * from Test;

This indicates that there is logical corruption in the datafile:

ORA-01578: ORACLE data block corrupted (file # 10, block # 198)
ORA-01110: data file 10: '/ora01/dbfile/O11R2/users201.dbf'
ORA-26040: Data block was loaded using the NOLOGGING option

As the prior output indicates, the data in the table is unrecoverable. Use NOLOGGING only in situations
where the data isn’t critical or in scenarios where you can back up the data soon after it was created.

There are some quirks of NOLOGGING that need some explanation. You can specify logging characteristics at the database, tablespace, and object levels. If your database has been enabled to force logging, then this overrides any NOLOGGING specified for a table. If you specify a logging clause at the tablespace level, it sets the default logging for any CREATE TABLE statements that don’t explicitly use a logging clause.

You can verify the logging mode of the database as follows:
SQL> select name, log_mode, force_logging from v$database;
The next statement verifies the logging mode of a tablespace:
SQL> select tablespace_name, logging from dba_tablespaces;
And this example verifies the logging mode of a table:
SQL> select owner, table_name, logging from dba_tables where logging = 'NO';

1 comment:

  1. Jadwal Arena Sabung Ayam SV388 28 Februari 2019 - Kamis, Maluku 28 Februari 2019 – Pada Hari Tersebut Akan Di Laksanakan Berbagai Pertandingan Sabung Ayam Secara Live di Arena Sabung Ayam Thailand.

    Situs Judi Sabung Ayam Online SV388 Merupakan Situs Judi Asal Thailand Yang Sangat Terkenal Dengan Permainan Sabung Ayam Yang Fair dan Menghibur Para Penonton Judi Sabung Ayam.

    Untuk Info Lebih Lanjut Bisa Hub kami Di :
    wechat : bolavita
    line : cs_bolavita
    whatsapp : +628122222995
    BBM: BOLAVITA

    ReplyDelete