Preload data

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
geanni
Posts: 10
Joined: Wed 28 Jul 2010 22:18

Preload data

Post by geanni » Tue 19 Jun 2012 17:02

Hi,

I have a grid connected to a ClientDataSet. Everything works fine till the amount of data to be displayed increase. In case we have 40000 rows it becomes very slow. Is there any possibility to preload (paginate) somehow automatically the loading of data?

Geanni

AndreyZ

Re: Preload data

Post by AndreyZ » Wed 20 Jun 2012 07:25

Hello,

To solve the problem, you should set the FetchAll property to False. Here is a code example:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
  MyQuery1.FetchAll := False;
  MyQuery1.FetchRows := 25;
  DataSetProvider1.DataSet := MyQuery1;
  ClientDataSet1.SetProvider(DataSetProvider1);
  ClientDataSet1.PacketRecords := 25;
  ClientDataSet1.Open;
end;
In this case data will be fetched by 25 records when it is explicitly requested.

Post Reply