UniDac Firebird FetchRows

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
abed
Posts: 15
Joined: Mon 27 Apr 2009 16:39

UniDac Firebird FetchRows

Post by abed » Sat 06 Sep 2014 22:41

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

stevel
Posts: 125
Joined: Tue 02 Nov 2010 19:01

Re: UniDac Firebird FetchRows

Post by stevel » Sun 07 Sep 2014 16:58

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.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: UniDac Firebird FetchRows

Post by ViktorV » Mon 08 Sep 2014 07:04

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.

abed
Posts: 15
Joined: Mon 27 Apr 2009 16:39

Re: UniDac Firebird FetchRows

Post by abed » Wed 17 Sep 2014 08:27

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.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: UniDac Firebird FetchRows

Post by ViktorV » Thu 18 Sep 2014 11:14

It is good to see that the problem has been solved. If any questions concerning our products come up, please contact us.

Post Reply