How to improve clientdataset query performance with many records?

Asked

Viewed 2,571 times

4

When I am searching for all the clients table record, which are many, from a remote database and displaying on a Dbgrid, this process takes a lot of time.

How do I improve the performance of clientdataset query when many records are returned?

2 answers

3

Use the property PacketRecords to determine how many records should be returned in each package by the previous.

This way the data will be returned quickly but the whole information will take longer to be returned and displayed gradually

The property behaves differently depending on its value:

  • -1: Returns all records
  • 0: Returns only the metadata
  • >0: Returns the amount of records reported with each request to the User

Example

ClientDataSet1.FetchOnDemand :=True;  
ClientDataSet1.PacketRecords := 100;

For more information, see here on the site of Embarcadero

0

the best way would be to optimize the SQL command by placing the smallest possible number of junctions (left or Inner Join).

In summary seeking good programming practices and SQL commands.

If you want to perform a query before the command already informed in Clientdatabeing the fastest way would be to use the filter option

clientDataSet.filtered := False;
clientDataSet.filte    := '';
clientDataSet.filter   := 'Condição';
clientDataSet.filtered := True;

With this method the clientDataSet does not perform a new query only filters the records that are stored in it

Browser other questions tagged

You are not signed in. Login or sign up in order to post.