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?
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?
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:
ClientDataSet1.FetchOnDemand :=True;
ClientDataSet1.PacketRecords := 100;
For more information, see here on the Embarcadero website
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