BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TClientdataSet very slow?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress)
View previous topic :: View next topic  
Author Message
Harald
Guest





PostPosted: Sat Nov 22, 2003 9:39 pm    Post subject: TClientdataSet very slow? Reply with quote



Hi

First the test code, a TForm with a button on it:

procedure TForm1.Button1Click(Sender: TObject);
var
i : integer;
begin
DataSet:=TClientDataSet.Create(nil);

with DataSet.FieldDefs.AddFieldDef do
begin
DataType:=ftInteger;
Name:='test';
end;
DataSet.CreateDataSet;

for i:=1 to 5000 do
begin
DataSet.Edit;
DataSet.FieldByName('test').AsInteger:=i;
DataSet.Post;

button1.Caption:=inttostr(i);
button1.Update;
end;
end;

The count up to about 500 is very fast but then is slows down and gets
slower and slower, why?

I am using Delphi 7 pro.

/HK



Back to top
Bill Todd
Guest





PostPosted: Sat Nov 22, 2003 10:37 pm    Post subject: Re: TClientdataSet very slow? Reply with quote



On Sat, 22 Nov 2003 22:39:09 +0100, "Harald" <news10 (AT) kroning (DOT) dk>
wrote:

Quote:
The count up to about 500 is very fast but then is slows down and gets
slower and slower, why?

Because TClientDataSet was not designed to handle large amounts of
data. Others may give you a more technical explanation of how the
memory manager works and why it gets slower as the volume of data gets
larger but it all boils down to the fact that it was never intended to
handle tens of thousands of records.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)

Back to top
Harald
Guest





PostPosted: Sat Nov 22, 2003 11:28 pm    Post subject: Re: TClientdataSet very slow? Reply with quote



"Bill Todd" <no (AT) no (DOT) com> skrev i en meddelelse
news:75pvrv8u454li0al1ludue666i38d6mlmu (AT) 4ax (DOT) com...
Quote:
On Sat, 22 Nov 2003 22:39:09 +0100, "Harald" wrote:

The count up to about 500 is very fast but then is slows down and gets
slower and slower, why?

Because TClientDataSet was not designed to handle large amounts of
data. Others may give you a more technical explanation of how the
memory manager works and why it gets slower as the volume of data gets
larger but it all boils down to the fact that it was never intended to
handle tens of thousands of records.

But there is only one record in my test, I just change the same record over
and over again, I use Edit not Append or Insert.

/HK



Back to top
Bill Todd
Guest





PostPosted: Sun Nov 23, 2003 2:30 am    Post subject: Re: TClientdataSet very slow? Reply with quote

Sorry. I did not look at your code closely. I thought you were using
5,000 different records. I am not sure why the performance degrades if
you change the same record 5,000 times.


--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
Back to top
Brian Cook
Guest





PostPosted: Sun Nov 23, 2003 2:51 am    Post subject: Re: TClientdataSet very slow? Reply with quote

Quote:
Hi

Greetings.


Quote:
The count up to about 500 is very fast but then is slows down and gets
slower and slower, why?

It must have something to do with logging changes. Add this...

DataSet.LogChanges := False;

....after this...

DataSet.CreateDataSet;

....and the code is lightning fast.


On my computer, the code you posted runs...

After Edits per Second
----- ----------------
1s 1147
2s 302
3s 212
4s 168
5s 142
6s 124
7s 111
8s 101
9s 93

So it is DEFINATELY slowing down.


Quote:
I am using Delphi 7 pro.

Delphi 6 exhibits the same behaviour.


- Brian

Back to top
Harald
Guest





PostPosted: Sun Nov 23, 2003 10:27 am    Post subject: Re: TClientdataSet very slow? Reply with quote

"Brian Cook" <bcook@rowdydogsoftware[REMOVE].com> skrev i en meddelelse
news:MPG.1a29c1f37562d45b9897be (AT) newsgroups (DOT) borland.com...
Quote:
Hi

Greetings.


The count up to about 500 is very fast but then is slows down and gets
slower and slower, why?

It must have something to do with logging changes. Add this...

DataSet.LogChanges := False;

...after this...

DataSet.CreateDataSet;

...and the code is lightning fast.

And now it works perfectly, thanks

/HK



Quote:
On my computer, the code you posted runs...

After Edits per Second
----- ----------------
1s 1147
2s 302
3s 212
4s 168
5s 142
6s 124
7s 111
8s 101
9s 93

So it is DEFINATELY slowing down.


I am using Delphi 7 pro.

Delphi 6 exhibits the same behaviour.


- Brian



Back to top
Joe Griffin
Guest





PostPosted: Mon Nov 24, 2003 6:34 pm    Post subject: Re: TClientdataSet very slow? Reply with quote

Brian Cook wrote:
Quote:
It must have something to do with logging changes.

Without your "DataSet.LogChanges := False;", it's writing the deltas
back to the CDS (so that it can be rolled back). IIRC, that's two
records for every change (what it was and what it changes to). That's a
LOT of data.

... Joe
Member of the UK Borland User Group


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.