🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: It is too many slow...

#3860
From: Jurko
Date: Sat, 08 Jun 2002 16:02
120 lines
5409 bytes
One suggestion... get the TField pointers out first using FieldByName and
then
use those TField pointers to set the data and not FieldByName every time...
that
will most defenetively speed up your program...

like this:


TADOTable* const table( DataModule1->ADOTable1 );
TField* const fld_level( table->FieldByName("Level") );
TField* const fld_term( table->FieldByName("Term") );
TField* const fld_bt( table->FieldByName("BT") );
...
{
    table->Append();
    fld_level->AsInteger = ...;
    fld_term->AsString = ...;
    fld_bt->AsString = ...;
    ...
}

(This is a wild guess as I don't know the exact way you're connecting
to your database:) I would suggest against using server side cursors...
or directly changing the data in the database with each line. Use server
side cursors if the amount of data is too big for your client, but in that
case use batch updates.

HTH,
    Jurko

"M. Noroozi Eghbali" <galaxy@irandoc.ac.ir> wrote in message
news:3d021be7_2@dnews...
> Hi,
>
> I am using an ADOTable and a DataSource (Microsoft.Jet.OLEDB.4.0) to save
my
> database in an Access file. It has about 25 fields and none of them are
> indexed. The number of records is about 60000. When I start the saving to
> the Access file, in the first second about 100 records were saved. The
> saving speed gradually decreases inasmuch as after 15000 records the
saving
> speed reaches to maximum 1 record per second. I wrote the code of the
saving
> function here. please tell me what is the wrong.
>
> Regards,
> Mehrdad
>
> void __fastcall TForm1::Save(TTreeNode *Node)
> {
>  typedef CNodeData* PNodeData;
>      TTreeNode *ChildNode;
>
>  do
>      {
>       DataModule1->ADOTable1->Append();
>           DataModule1->ADOTable1->FieldByName("Level")->AsInteger =
> Node->Level;
>           DataModule1->ADOTable1->FieldByName("Term")->AsString =
> Node->Text;
>           DataModule1->ADOTable1->FieldByName("BT")->AsString =
> PNodeData(Node->Data)->BT;
>           DataModule1->ADOTable1->FieldByName("NT")->AsString =
> PNodeData(Node->Data)->NT;
>           DataModule1->ADOTable1->FieldByName("RT")->AsString =
> PNodeData(Node->Data)->RT;
>           DataModule1->ADOTable1->FieldByName("SN")->AsString =
> PNodeData(Node->Data)->SN;
>           DataModule1->ADOTable1->FieldByName("UF")->AsString =
> PNodeData(Node->Data)->UF;
>           DataModule1->ADOTable1->FieldByName("Translate1")->AsString =
> PNodeData(Node->Data)->Translate1;
>           DataModule1->ADOTable1->FieldByName("Translate2")->AsString =
> PNodeData(Node->Data)->Translate2;
>           DataModule1->ADOTable1->FieldByName("Translate3")->AsString =
> PNodeData(Node->Data)->Translate3;
>           DataModule1->ADOTable1->FieldByName("Hide")->AsBoolean =
> PNodeData(Node->Data)->Hide;
>           DataModule1->ADOTable1->FieldByName("Status")->AsInteger =
> PNodeData(Node->Data)->Status;
>           DataModule1->ADOTable1->FieldByName("InputDate")->AsString =
> PNodeData(Node->Data)->InputDate;
>           DataModule1->ADOTable1->FieldByName("ApprovalDate")->AsString =
> PNodeData(Node->Data)->ApprovalDate;
>           DataModule1->ADOTable1->FieldByName("LastUpdate")->AsString =
> PNodeData(Node->Data)->LastUpdate;
>           DataModule1->ADOTable1->FieldByName("NotValidDate")->AsString =
> PNodeData(Node->Data)->NotValidDate;
>           DataModule1->ADOTable1->FieldByName("ABB")->AsString =
> PNodeData(Node->Data)->ABB;
>           DataModule1->ADOTable1->FieldByName("SC")->AsString =
> PNodeData(Node->Data)->SC;
>   DataModule1->ADOTable1->FieldByName("HN")->AsString =
> PNodeData(Node->Data)->HN;
>   DataModule1->ADOTable1->FieldByName("SF")->AsString =
> PNodeData(Node->Data)->SF;
>   DataModule1->ADOTable1->FieldByName("CA")->AsString =
> PNodeData(Node->Data)->CA;
>   DataModule1->ADOTable1->FieldByName("EC")->AsString =
> PNodeData(Node->Data)->EC;
>   if(PNodeData(Node->Data)->Frequency.IsEmpty())
>            DataModule1->ADOTable1->FieldByName("Frequency")->AsInteger =
0;
>           else
>            DataModule1->ADOTable1->FieldByName("Frequency")->AsInteger =
> StrToInt(PNodeData(Node->Data)->Frequency);
>           DataModule1->ADOTable1->FieldByName("Description")->AsString =
> PNodeData(Node->Data)->Description;
>
>           DataModule1->ADOTable1->Post();
>
> ...
> //Some codes to obtain next record from memory.
> ...
>
>      }while(Node);
> }
>
>
Technical Details
Message-ID: <cq9tda.sv8.ln@news.ve-mil.hr>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-08!supernews.com!newspump.sol.net!news.maxwell.syr.edu!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!dnews!news.ve-mil.hr!not-for-mail
References: <3d021be7_2@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,856e9c01d3c42b29
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2002-06-08 09:12:09 PST
From: "Jurko" <Jurko@ve-mil.hr>
Newsgroups: borland.public.cppbuilder.database.ado
References: <3d021be7_2@dnews>
Subject: Re: It is too many slow...
Date: Sat, 8 Jun 2002 18:02:44 +0200
Lines: 122
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Message-ID: <cq9tda.sv8.ln@news.ve-mil.hr>
NNTP-Posting-Host: 195.29.221.130
X-Trace: dnews 1023552349 195.29.221.130 (8 Jun 2002 09:05:49 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-08!supernews.com!newspump.sol.net!news.maxwell.syr.edu!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!dnews!news.ve-mil.hr!not-for-mail