TZQuery fetch control
Posted: 09.12.2014, 17:58
Hi!
Can TZQuery or TZReadOnlyQuery fetch records on demand by configurable portions (records number).
Something like http://docwiki.embarcadero.com/RADStudi ... t_Fetching:
"FireDAC is fetching rowsets according to the FetchOptions.Mode property:
fmOnDemand--the rowset is automatically fetched when the dataset is trying to move the current position beyond the last fetched record."
'select * from table limit XXX' is not an option.
I check FetchRow in select from table with 37700 records (PostgreSQL).
FetchRow seems don't do what it should: with FetchRow := 0 or FetchRow : = 10 program loads from DB all rows in app memory, regardless of FetchRow value.
This is proved by application memory consumption right after TZQuery.Open: its the same with FetchRow := 0 or FetchRow : = 10.
There is only one visual effects of FetchRow - after TZQuery.Open DBGrid shows only FetchRow rows, but all records already loaded from server into memory .
Next evedence about FetchRow is sources (ZEOSDBO-7.1.4-stable.zip).
ZQuery.Open calls
TZAbstractRODataset.InternalOpen where all records loaded
Next
where MaxRows is not at all about fetching portion by portion:
It only hard limit maximum records can readed into dataset.
Conclusion
TZAbstractRODataset.InternalOpen load all records into dataset from DB regardless of FetchRow value.
Am I wrong and maybe there is options?
Can TZQuery or TZReadOnlyQuery fetch records on demand by configurable portions (records number).
Something like http://docwiki.embarcadero.com/RADStudi ... t_Fetching:
"FireDAC is fetching rowsets according to the FetchOptions.Mode property:
fmOnDemand--the rowset is automatically fetched when the dataset is trying to move the current position beyond the last fetched record."
'select * from table limit XXX' is not an option.
I check FetchRow in select from table with 37700 records (PostgreSQL).
FetchRow seems don't do what it should: with FetchRow := 0 or FetchRow : = 10 program loads from DB all rows in app memory, regardless of FetchRow value.
This is proved by application memory consumption right after TZQuery.Open: its the same with FetchRow := 0 or FetchRow : = 10.
There is only one visual effects of FetchRow - after TZQuery.Open DBGrid shows only FetchRow rows, but all records already loaded from server into memory .
Next evedence about FetchRow is sources (ZEOSDBO-7.1.4-stable.zip).
ZQuery.Open calls
TZAbstractRODataset.InternalOpen where all records loaded
Code: Select all
...
{ Creates an SQL statement and resultsets }
if not FUseCurrentStatment then
if FSQL.StatementCount> 0 then
ResultSet := CreateResultSet(FSQL.Statements[0].SQL, -1) // LOAD ALL RECORDS (memory consumption pops to max)
Code: Select all
function TZAbstractRODataset.CreateResultSet(const SQL: string; MaxRows: Integer): IZResultSet;
Code: Select all
if MaxRows > 0 then
Statement.SetMaxRows(MaxRows);
...
Result := Statement.ExecuteQueryPrepared; // after execution memory consumption pops to max
Conclusion
TZAbstractRODataset.InternalOpen load all records into dataset from DB regardless of FetchRow value.
Am I wrong and maybe there is options?