[DUG] Speed of loading a Client DataSet
Myles Penlington
myles at ams.co.nz
Thu Dec 6 15:56:47 NZDT 2007
Stop using FieldByName inside the loop - this is a linear search of the
Fields in the dataset.
Myles.
-----Original Message-----
From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz]
On Behalf Of John Bird
Sent: Thursday, 6 December 2007 3:36 p.m.
To: 'NZ Borland Developers Group - Delphi List'
Subject: [DUG] Speed of loading a Client DataSet
I want to use TClientDataSet for data that is NOT in a database.
Just reading the data from a file, eg for 15000 records, takes much less
than a second, but reading the data and inserting several fields into a
client dataset in a simple loop takes a lot longer, eg 6 seconds or more
for
the same 15000 records.
The code I am using is like:
with tbData do
begin
append;
fieldbyname('FieldName1').asInteger:=Number1;
fieldbyname('FieldName2').asInteger:=Number2;
fieldbyname('FieldName3').asInteger:=Number3;
fieldbyname('Name').asString:=Name;
fieldbyname('Desc').asString:=Desc;
post;
end;
I would like to speed this up, as I have seen that reading similar data
from
a Database eg with a query is much faster. Any suggestions to speed
this
up?
I already have lines in such as
tbdata.DisableControls;
tbdata.EnableControls;
Before and after I start reading the data to stop screen updates....
John
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi at delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-request at delphi.org.nz with Subject:
unsubscribe
Attention:
This communication is confidential and may be legally privileged. If you are not the intended recipient, please do not use, disclose, copy or distribute it, other than to return it to us with your confirmation that it has been deleted from your system.
More information about the Delphi
mailing list