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

Posts: 1
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
 
When You Register, These Ads Go Away!
Old 01-06-2007, 09:19 AM Re: optimize insert to mdb
tripy's Avatar
Fetchez la vache!

Posts: 2,171
Name: Thierry
Location: In the void
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
 
Old 01-06-2007, 05:26 PM Re: optimize insert to mdb
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,024
Name: Forrest Croce
Location: Seattle, WA
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

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

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


Webmaster Resources Marketplace:
Software Development Company | Webhosting.UK.com | Text Link Brokers 


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

 


Page generated in 0.14062 seconds with 12 queries