Page 1 of 1
UniDac Firebird FetchRows
Posted: Sat 06 Sep 2014 22:41
by abed
Hello,
When i set the FetchRows in TuniQuery =25,
means that i only load 25 records?
example :
with UniQuery do
begin
FetchRows:=25;
Sql.Text := 'SELECT * FROM EMPLOYEES ORDER BY UniqueEmpID' (150000) recs
Open;
while Not Eof
begin
Next.. (25 times)
end;
end;
Is that a correct behaviour?
I don’t want to use fetchall, it's not practical
I expect that when reaches the 25 (fetchRows) load the next 25 records.
Waiting for your advise
Re: UniDac Firebird FetchRows
Posted: Sun 07 Sep 2014 16:58
by stevel
With "FetchRows := 25", your SQL query of:
"SELECT * FROM tblStudents"
will fetch only 25 rows.
Your loop will fetch one row at a time, and when it hits 25 (and multiples of 25) rows, the request for the next row will fetch the next 25 rows from the database server resultset cursor.
However your statement with comment "Next (25 times)" is not accurate because it the loop will execute 150,000 times until EOF becomes true. Resultset rows will be fetched from the server cursor to the buffer on the client PC 25 rows at a time.
I would optimize this to make it fetch a larger number of rows at a time. You need to calculate the optimum amount based on the maximum size in bytes of each record in that table (or average maximum size in bytes of a record) and the latency of your LAN / WAN network.
Re: UniDac Firebird FetchRows
Posted: Mon 08 Sep 2014 07:04
by ViktorV
Yes, this is the right answer.
The FetchRows property determines the count of records that are fetched when the dataset is scrolled to the last fetched record.
For example, if FetchRows is set to 25, the dataset first fetches 25 records. When you move to the record #26, it fetches next 25 records.
Re: UniDac Firebird FetchRows
Posted: Wed 17 Sep 2014 08:27
by abed
thanks for your reply,
I found the problem why I have got only 25 records, as I'm using readonly cursor to avoid alive transactions for long tine, it was not enough to use common defaulttransaction but must create a specialized one.
n.b.
if you set the default transaction isolation level ilReadCommited and ReadOnly all your select query w’ll goes EOF after the Fetchrows Nr.
Re: UniDac Firebird FetchRows
Posted: Thu 18 Sep 2014 11:14
by ViktorV
It is good to see that the problem has been solved. If any questions concerning our products come up, please contact us.