Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
optimize insert to mdb
Old 11-23-2006, 08:52 AM optimize insert to mdb
Junior Talker

Posts: 1
Trades: 0
Hi,
I'm using access tables to store my data. to retrive data I use jet odbc engine in c++.
I want to insert a large amuont of records (about 20 mega records) to my database in the fasts way i can. if i use sql syntax (insert into table ()....) it's takes for ages (about 500 records per second).
if i'm writing a csv file and then use import (via access) it's much faster but still takes a long time, i can live with that only i dont know how to use the access import tool from c++.
does any know any tool that insert records in an optimize way, or how to use the access import tool in c++? can i use the jet engine for it?
thank ishay
ishaywei is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-06-2007, 09:19 AM Re: optimize insert to mdb
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
you should use a transaction.

Code:
begin;

insert into {table} ({fields}) values ({values})
insert into {table} ({fields}) values ({values})
insert into {table} ({fields}) values ({values})
insert into {table} ({fields}) values ({values})
insert into {table} ({fields}) values ({values})
...
...
...
...

commit;
That way, the db will commit and recalculate the indexes and so on only on the commit statement, and not on each insert.
That can already help, but your DB need to support it.

You could try to use a binded query too.
Look on your db reference for more infos.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 01-06-2007, 05:26 PM Re: optimize insert to mdb
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,023
Name: Forrest Croce
Location: Seattle, WA
Trades: 0
Quote:
Originally Posted by tripy View Post
you should use a transaction.

That way, the db will commit and recalculate the indexes and so on only on the commit statement, and not on each insert.
That can already help, but your DB need to support it.

You could try to use a binded query too.
Look on your db reference for more infos.

Also, if you don't (explicitly) use transactions, the database will use them implicitly. But, it'll wrap each SQL command in its own transaction. This is a great deal of work, and doing it once per session, instead of once per record, should make a tremendous difference.

What do you mean when you say "20 mega" records? 20 million?
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
Reply     « Reply to optimize insert to mdb
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.17860 seconds with 12 queries