Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Fastest way to import textfile record into database

Posted on 2009-05-10
9
Medium Priority
?
311 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 28

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

618 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