i have problem retrieving data with Delphi TClientDataSet
Code with ADO:
ADOQuery1.SQL.Text:='SELECT * FROM Table1 WITH (NoLock)';
DataSource1.DataSet:=ADOQuery1;
DataSource1.DataSet.Open;
DataSource1.DataSet.Last;
Code above returns over 180k rows in 3-6 seconds when using pure ADO.
Same code with TClientDataSet:
ADOQuery1.SQL.Text:='SELECT * FROM Table1 WITH (NoLock)';
CDS1.SetProvider(ADOQuery1);
DataSource1.DataSet:=CDS1;
DataSource1.DataSet.Open;
DataSource1.DataSet.Last;
Following code returns same amount of rows(over 180k) but within 3-4minutes.
What's wrong with CDS? It's about 100-times slower then using ADO. Is it possible to fix it?
CursorLocation
, you may be getting only the first few and last few rows. There are also other settings that that can give ADO an opprtunity to implement certain efficiency improvements. E.g. If configured to read "forwards-only", ADO would not need to store or process any intermediate rows when you executeDataSet.Last
. – TenementTClientDataSet
is probably not the best tool for your requirements.) – TenementTDataSet
descendants are slow in general. For fetching optimize the query to use a forward, read only cursor and access the underlyingRecordset
interface. @mjn, it's not documented as well as it's not documented how many items is reasonable to use e.g. withTList
. – Subnormal