Article View: borland.public.cppbuilder.database.ado
Article #4399Re: Speed up Database
From: BM
Date: Tue, 18 Dec 2001 10:44
Date: Tue, 18 Dec 2001 10:44
56 lines
2934 bytes
2934 bytes
First of all I'm a Delphi programmer and my comments/code is from memory.
What you want is something like
query1->Prepare;
for (i=0;i<9800000;i++)
{
query1->ParamByName("f1")->AsString = f1[i];
........................................................................
query1->ParamByName("fn")->AsString = fn[i];
query1->Execute;
}
query1->UnPrepare;
in your ado query component you'll have some sql like ...
INSERT INTO MYTABLE (f1, ... fn) VALUES(:f1, ... fn)
1) The point is that SQL in the query only refers to the columns you want to
set values for (i.e. f1, f2 ...) and this update is performed at the
database; you are not literally requiring the whole table to be brought down
first to be changed
2) I think preparing the query may not be valid for ADO components (you can
check if this is supported) but if it is then it could improve performance.
3) If you are using ADO Express I think its been found that performance can
be slow. The alternative is to use to import the ADO type library, ADOInt,
and essentially use ADO directly in code (no visual components here)
4) If you insist on using the table component posting the records at the end
only may help as appending records implicitly posts the last record (i.e you
moving off the last inserted record results in it being posted
automatically) i.e.
for (i=0;i<9800000;i++)
{
Table1->Append();
Table1->FieldByName("f1")->AsString = f1[i];
........................................................................
Table1->FieldByName("fn")->AsString = fn[i];
}
Table1->Post();
"Avex" <I@dont.like.spammar> wrote in message news:3c1ef4d8_1@dnews...
> I dont understand, would you plz give me an example ?
>
> "Ray" <SpamBlows@everywhere.com> wrote
> :3C1EB39E.D8A8EE26@everywhere.com...
> > instead of using a table use a query so that the whole table
> > doesnt have to be loaded
> > and maybe post all the records at the end..not each individually
> >
> >
> >
>
Technical Details
Message-ID:
<3c1f3000_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news-out.visi.com!hermes.visi.com!out.nntp.be!propagator-SanJose!in.nntp.be!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnewsReferences:
<3c1eb21f_1@dnews> <3C1EB39E.D8A8EE26@everywhere.com> <3c1ef4d8_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,77d6545c02a2aaf5 X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2001-12-18 04:04:15 PST From: "BM" <m02x7z00@cwcom.net> Newsgroups: borland.public.cppbuilder.database.ado References: <3c1eb21f_1@dnews> <3C1EB39E.D8A8EE26@everywhere.com> <3c1ef4d8_1@dnews> Subject: Re: Speed up Database Date: Tue, 18 Dec 2001 10:44:15 -0000 Lines: 58 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 NNTP-Posting-Host: 62.253.93.59 Message-ID: <3c1f3000_1@dnews> X-Trace: dnews 1008676864 62.253.93.59 (18 Dec 2001 04:01:04 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news-out.visi.com!hermes.visi.com!out.nntp.be!propagator-SanJose!in.nntp.be!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews