🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #191

Re: Fastest Way to Insert a Number of Records via SQL

#191
From: Vassiliev V. V.
Date: Mon, 04 Jun 2007 20:35
60 lines
3516 bytes
For Access (but not for most other DBMS) try to use TADOTable with
CursorLocation = crServer. Using transaction (open transaction, insert 5000
or 19000 rows, then commit transaction, then start new transation etc.) will
also speed up inserts (again, for other DBMS this may or may be not true).
For best results you may look at third-party components, but they may
require more code.

//------------------------------------------
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:46645ac3@newsgroups.borland.com...
> Hi Folks,
>
> I need some help. I have some tables that I want to move to Access.  But 
> moving the data from one format to the other seems to take FOREVER with my 
> code.
>
> For simplicity, the source is basically two tables, a source table which 
> contains header information and forms the basis of a link to the 12 
> records in a subtable.  The sub table is basically a memo field containing 
> table-link information that, each of which has 3 fields, containing 520 
> records.  The new target format I am moving to basically breaks out that 
> memo into 520 unique records in each of three tables.
>
> As you could see, to import one complete record from the source, I would 
> have to add the following number of records to the target:
>
> 1 Header Record
> And then 12x representing each expanded subtable:
>   520 (1st field) records
>   520 (2nd field) records
>   520 (3rd field) records
>
> This is ends up being 6240+6240+6240+1 = 18,721 records!
>
> Oh, why the new format?? why???  Seriously though, there are reasons for 
> it!  For starters, the 1st and 2nd fields are the same in each 12 
> sub-tables, so I can get away with only adding them once.  Then, there are 
> a number of mathematical operations I would like to easily perform on the 
> data, that can be performed via SQL, that it is another bonus; there are 
> more.
>
> So, performing 19K Insert statements, like I said, TAKES FOREVER.
> What is the best way to do this besides the following pseudo:
>   TADOQuery *Query;
>   Query->SQL->Text = "INSERT ONE RECORD SQL STATEMENT"
>   Quey->ExecSQL();
>
> and then looping thru 19k more times?
>
>
> Thanks in advance!
>
> Dan 
Technical Details
Message-ID: <466477c6$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <46645ac3@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>
Subject: Re: Fastest Way to Insert a Number of Records via SQL
Date: Tue, 5 Jun 2007 00:35:22 +0400
Lines: 62
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
X-Antivirus: avast! (VPS 000747-0, 04.06.2007), Outbound message
X-Antivirus-Status: Clean
NNTP-Posting-Host: 85.93.138.132
Message-ID: <466477c6$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1180989382 85.93.138.132 (4 Jun 2007 13:36:22 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail