How to improve clientdataset query performance with many records?

4

When I'm looking for all records of the many clients table, from a remote database and displaying in a DBGrid, this process takes a long time.

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

    
asked by anonymous 12.03.2015 / 13:28

2 answers

3

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

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

The property behaves differently, depending on its value:

  • -1: Returns all records
  • 0: Only returns metadata
  • > 0: Returns the number of records reported to each request to the provider

Example

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

For more information, see here on the Embarcadero website

    
12.03.2015 / 14:39
0

The best way would be to optimize the SQL command by putting as few joins as possible (left or inner join).

In summary, we are looking for good programming practices and SQL commands.

If you want to query the command already informed in ClientDataSer, the fastest way would be to use filter

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

    
07.01.2016 / 14:38