| View previous topic :: View next topic |
| Author |
Message |
Harald Guest
|
Posted: Sat Nov 22, 2003 9:39 pm Post subject: TClientdataSet very slow? |
|
|
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
|
Posted: Sat Nov 22, 2003 10:37 pm Post subject: Re: TClientdataSet very slow? |
|
|
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
|
Posted: Sat Nov 22, 2003 11:28 pm Post subject: Re: TClientdataSet very slow? |
|
|
"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
|
Posted: Sun Nov 23, 2003 2:30 am Post subject: Re: TClientdataSet very slow? |
|
|
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
|
Posted: Sun Nov 23, 2003 2:51 am Post subject: Re: TClientdataSet very slow? |
|
|
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
|
Posted: Sun Nov 23, 2003 10:27 am Post subject: Re: TClientdataSet very slow? |
|
|
"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
|
Posted: Mon Nov 24, 2003 6:34 pm Post subject: Re: TClientdataSet very slow? |
|
|
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 |
|
 |
|