Subject Re: [Firebird-Java] Fetch size questions
Author Roman Rokytskyy
> If I call statement.setFetchSize(20), then Firebird will send at
> least twenty records, but probably more because it will try to fill
> every network packet. Is this correct?

If you call statement.setFetchSize(20), then statement.executeQuery() and
then rs.next(), then driver will call isc_dsql_fetch and check how many rows
it received. If it received 12 rows, it will call isc_dsql_fetch again, and
will receive 17 more records (if you have VARCHAR columns, size of each
record will vary). At that time it has 29 records, so the execution leaves
the ResultSet.next() method. After this next 28 rs.next() calls will happen
almost instant, only the record number is increased. When you try to go to
record 30, driver will find out that there is no record in cache and it will
call isc_dsql_fetch as many times as needed to cache at least 20 records.
And so on.

Roman