I have CSV and TXT files to import. I am importing the files into Access and then inserting the records into a linked Oracle table. Each file has around 3 million rows and the process is taking a long time to complete.
Importing into Access is very fast, but inserting into the linked Oracle table is taking an extremely long time.
Here is the process I am currently using:
DoCmd.TransferText acImportFixed, "BUSSEP2014 Link Specification", "tblTempSmartSSP", strFName, False
db.Execute "INSERT INTO METER_DATA ([MPO_REFERENCE]) SELECT MPO_REFERENCE FROM tblTempSmartSSP;"`
tblTempSmartSSP
is an Access Table and METER_DATA
is a linked Oracle table
I also tried direct import to linked table and that was also very slow.
How can I speed up the process?
Do you have to import all the columns? Maybe you want to leave out empty columns, if any; and also columns which are not absolutely necessary for business purposes
Sorry, I forgot to include the code:
This situation is not uncommon when dealing with bulk INSERTs to ODBC linked tables in Access. In the case of the following Access query
where [METER_DATA] is an ODBC linked table and [tblTempSmartSSP] is a local (native) Access table, ODBC is somewhat limited in how clever it can be because it has to be able to accommodate a wide range of target databases whose capabilities may vary greatly. Unfortunately, it often means that despite the single Access SQL statement what actually gets sent to the remote (linked) database is a separate INSERT (or equivalent) for each row in the local table. Understandably, that can prove to be very slow if the local table contains a large number of rows.
Option 1: Native bulk inserts to the remote database
All databases have one or more native mechanisms for the bulk loading of data: Microsoft SQL Server has "bcp" and
BULK INSERT
, and Oracle has "SQL*Loader". These mechanisms are optimized for bulk operations and will usually offer significant speed advantages. In fact, if the data needs to be imported into Access and "massaged" before being transferred to the remote database it can still be faster to dump the modified data back out to a text file and then bulk import it into the remote database.Option 2: Using a pass-through query in Access
If the bulk import mechanisms are not a feasible option, then another possibility is to build one or more pass-through queries in Access to upload the data using INSERT statements that can insert more than one row at a time.
For example, if the remote database was SQL Server (2008 or later) then we could run an Access pass-through (T-SQL) query like this
to insert three rows with one INSERT statement.
According to an answer to another earlier question here the corresponding syntax for Oracle would be
I tested this approach with SQL Server (as I don't have access to an Oracle database) using a native [tblTempSmartSSP] table with 10,000 rows. The code ...
... took approximately 100 seconds to execute in my test environment.
By contrast the following code, which builds multi-row INSERTs as described above (using what Microsoft calls a Table Value Constructor) ...
... took between 1 and 2 seconds to produce the same results.
(T-SQL Table Value Constructors are limited to inserting 1000 rows at a time, so the above code is a bit more complicated than it would be otherwise.)