Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is more efficient INSERT command or SQL Loader for bulk upload - ORACLE 11g R2

As part of a new process requirement, we will be creating table and which will contain approximately 3000 - 4000 records. We have a copy of these records in plain text on a txt file.

Loading these records in the table leaves me with two choices

  1. Use a shell script to generate SQL file containing INSERT Statements for these records

    • with the use of awk, shell variables, and loops to create a sql and script execution of this sql, we can be performed with ease
  2. Use of SQL Loader.

    • Realignment of the record list and ctl file generation the only dependency.

Which of the above two options would be most efficient, in terms of taking up DB resources, utilisation on the client server on which this is to be performed.

I do realise the number of records are rather small, but we may have to repeat this activity with higher number of records (close to 60,000) in which case I would like to have the best possible option configured from the start.

like image 694
Venus D'souza Avatar asked Jan 11 '14 06:01

Venus D'souza


People also ask

Why SQL Loader is faster than insert?

A direct path load is faster than the conventional path for the following reasons: Partial blocks are not used, so no reads are needed to find them, and fewer writes are performed. SQL*Loader need not execute any SQL INSERT statements; therefore, the processing load on the Oracle database is reduced.

How can increase bulk insert performance in Oracle?

One of the most common ways to improve the performance of an INSERT operation is to use the APPEND optimizer hint. APPEND forces the optimizer to perform a direct path INSERT and appends new values above the high water mark (the end of the table) while new blocks are being allocated.

Which is fastest way to load data into Oracle?

SQL*Loader is the primary method for quickly populating Oracle tables with data from external files. It has a powerful data parsing engine that puts little limitation on the format of the data in the datafile. SQL*Loader is invoked when you specify the sqlldr command or use the Enterprise Manager interface.

How fast is SQL Loader?

It is also worth noting that the fastest import time achieved for this table (earlier) was 67 seconds, compared to 41 for SQL*Loader direct path - a 39% reduction in execution time. This proves that SQL*Loader can load the same data faster than import.


1 Answers

SQL*Loader is the more efficient method. It gives you more control. You have an option do DIRECT load and NOLOGGING, which will reduce redo log generation, and when indexes have been disabled (as part of direct loading), the loading goes faster. Downside, is if load is interupted, indexes are left unusable.

But, considering the advantages, SQL*Loader is the best approach. And you will feel the difference, when you have millions of records, and having so many loading jobs running in parallel. I heard DBA complaining about the log size, when we do CONVENTIONAL INSERT statement loading, with 200+ such jobs, running in parallel. The larger the data volume, the larger the difference you'll see in performance.

like image 107
Maheswaran Ravisankar Avatar answered Nov 06 '22 14:11

Maheswaran Ravisankar