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
Use a shell script to generate SQL file containing INSERT Statements for these records
Use of SQL Loader.
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.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With