How to make TClientDataSet.ApplyUpdates thread safe?


2004-01-18 03:17:48 PM
delphi72
My app allows a user to work in the briefcase model and periodically send
updates to the server.
Some of the mods that a user can make on a record have ripple effects such
that when one record is changed, 2000 other records are updated.
Saving the client data set locally is instantaneous even with 2000 records.
ApplyUpdates however is another matter.
To test its performance, I created two Datamodule:
dm_SS (data module server side) with an TADOTable connected to an access
database and a Client data set
that will write its data to an xml file.
dm_cs (data module client side) with a client data set and a data
provider.
I created a test app running locally (no network traffic).
Whether I point the data provider to the ado table or the client data set,
it requires about 36~37 seconds to apply updates for 2000 records. Yet, it
takes subsecond time to save the data to a file. I have got 500 megs of ram,
enough to run the app without paging... Since all is taking place in memory
until the data is written by the source.
Question1: What can I do to speed ApplyUpdates? Ideally, I'd like for
the data provider to pickup the delta,
in one scoop and make it available to the data source which can then loaded
into the database in one shot. Can using Firebird or MySQL improve the odds?
Question 2: The user won't mind if the apply update takes 36 seconds,
provided that it is happening in the background. Can I initiate a thread and
call applyupdates in that thread while the user is still working with the
client data set? If not, should I copy the delta of the client data set to
another client data set that is tied to the same data provider and let the
second client data set do the update in a thread (disabling the apply update
on the first client data set)?
Has anyone else seen these issues? How have you handled them?
Thanks.