Article View: borland.public.cppbuilder.database.ado
Article #201Re: Fastest Way to Insert a Number of Records via SQL
From: Vassiliev V. V.
Date: Sat, 09 Jun 2007 18:41
Date: Sat, 09 Jun 2007 18:41
55 lines
3342 bytes
3342 bytes
Using TADOCommand with parameters and Prepared = true should make inserts
faster. BatchUpdate() uses similar technique but doing this manually you may
do it faster.
How fast can you insert data depends not only on methods but on data (how
much columns, do you have BLOBs or not, how much indexes and which columns
are indexed, foreign keys etc), for example one example in OLEDB Direct
(http://www.oledbdirect.com) inserts 200'000 rows in 16.5 seconds, first
100'000 are inserted into table (using interfaces that TADOTable uses on low
level), second 100'000 rows are inserted inside transaction and second
100'000 rows are inserted in 4.5 seconds. However it is simple table without
indexes.
//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"Dan" <Dan@do.not.spam> ???????/???????? ? ???????? ?????????:
news:4669c1e0$1@newsgroups.borland.com...
> I'm still not at copy and paste speeds but was able to decrease insert
> times by over 80%.
>
> I started with this:
>
> TADOQuery *SQLObject = (pointer of actual object);
> do
> {
> SQLObject->SQL->Text = "Insert into [tablename] (fields...) VALUES
> (values..)";
> }
> while (still have to import huge number of records);
> SQLObject->ExecSQL();
>
>
> To increase I changed the above to something like this:
> TADOQuery *SQLObject = (pointer of actual object);
> SQLObject->SQL->Text = "Select (field) from [tablename] where (field
> doesn't already exist); //fast query to turn on SQL
> do
> {
> SQLObject->InsertRecords(ARRAYOFCONST((fieldvalues...)));
> }
> while (still have to import huge number of records);
> SQLObject->BatchUpdate(arAll);
>
>
> Any other suggestions on how to increase speed? I am presently at around
> 200ms for 520 records, and I'd like to be well less than 100ms
>
> Dan
Technical Details
Message-ID:
<466af4b9@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<46645ac3@newsgroups.borland.com> <466477c6$1@newsgroups.borland.com> <466580d1@newsgroups.borland.com> <4665925c@newsgroups.borland.com> <46659f88@newsgroups.borland.com> <4666194d@newsgroups.borland.com> <46665d06@newsgroups.borland.com> <4669c1e0$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,d0a6c05550b4cac9 X-Google-Attributes: gid10698b,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Vassiliev V. V." <support@oledbdirect.com> Newsgroups: borland.public.cppbuilder.database.ado References: <46645ac3@newsgroups.borland.com> <466477c6$1@newsgroups.borland.com> <466580d1@newsgroups.borland.com> <4665925c@newsgroups.borland.com> <46659f88@newsgroups.borland.com> <4666194d@newsgroups.borland.com> <46665d06@newsgroups.borland.com> <4669c1e0$1@newsgroups.borland.com> Subject: Re: Fastest Way to Insert a Number of Records via SQL Date: Sat, 9 Jun 2007 22:41:57 +0400 Lines: 57 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3028 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 X-RFC2646: Format=Flowed; Response X-Antivirus: avast! (VPS 000748-2, 09.06.2007), Outbound message X-Antivirus-Status: Clean NNTP-Posting-Host: 85.93.138.132 Message-ID: <466af4b9@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1181414585 85.93.138.132 (9 Jun 2007 11:43:05 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail