?
Solved

Fastest way to import textfile record into database

Posted on 2009-05-10
9
Medium Priority
?
312 Views
Last Modified: 2013-11-07
Any fast and efficient way for a console to read from a textfile, do format checking and duplication checking on row then insert the record into database? i would like to read from 100k line and insert into database in a short time. expect to insert 100k row record in 5-10 minute.
0
Comment
Question by:mkdev2009
7 Comments
 
LVL 6

Expert Comment

by:nirojexpert
ID: 24351360
the fastest way is to load using the sql loader. you can enable your constraints of data validation and unique constraints using the database features.
but if your database is not oracle, you have to use the suitable tool.
the main point is the use the tool provided by the database than making your own if you are really concerned with performance.
0
 
LVL 7

Expert Comment

by:Alpha Au
ID: 24351367
if you are using sql server, the fastest way to import a text file to db is BCP

you may check this out.

http://msdn.microsoft.com/en-us/library/ms162802.aspx
0
 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 24352654
Have you tried out the native loading techniques specfic to the databases.
Since you haven't specified your database, listing the options below:

1. SQL Server - BCP
2. Oracle - SQL Loader
3. DB2 - LOAD
4. Sybase - BCP
5. MySQL  - LOAD

By the way, these native loading techniques are the faster way to load text file into the appropriate tables.
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

Author Comment

by:mkdev2009
ID: 24354461
Hi all, thanks a lot for the reply.
FYI, i am using MSSQL as my database. curretly the txt file is uplaod via web portal,and the console need to read it, do the validation, and insert into DB.
Any idea to speed up during duplication checking?

nirojexpert,
the duplicate validation are base on 3 criteria, dun think the unique constraints  able to do the checking.
0
 
LVL 29

Expert Comment

by:Bill Bach
ID: 24354765
An ETL tool may be quite helpful here, as well.  Pervasive Data Integrator (www.pervasive.com) can provide all of the text parsing, deduplication, and database insertion.  The real performance is in the automated processing of the "Engine", but you can certainly do all of what you need (except for automated runs from a batch file) via the less-expensive Developers Seat license.
0
 
LVL 7

Expert Comment

by:Alpha Au
ID: 24360421
if the speed is concerned, i would suggest to batch insert the txt file into sql server table (create a table for temp storage)
then run a sp to do the deduplication and validation.

0
 
LVL 57

Accepted Solution

by:
Raja Jegan R earned 1500 total points
ID: 24360627
Since this is MS SQL Server, you can follow this procedure.

1. Create a temporary table with exactly the same structure as of your original table without any constraints.
2. BCP that flat file into a temporary table without any validation.
3. From the temporary table, INSERT / UPDATE records into your main table based along with the required validations.
4. Capture error records if any.

Hope this helps
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
What we learned in Webroot's webinar on multi-vector protection.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question