Subject Re: [firebird-support] How to implement "fetch data on demand" at SQL level
Author Ann W. Harrison
At 05:13 PM 12/19/2004, william_yuwei wrote:

> I have a 20 rows grid that I just want to implement "fetch data on
>demand" for it, that is I only want to fetch 20 rows data from server
>until the grid is scrolled, then fetch another 20 rows, so what should
>I do implement this purpose at SQL level (back end)?

The best way is to open a query for all the rows you might want,
fetch 20, do whatever, then when you want the next 20, fetch them.
Most interface programs won't let you do that, so theres a syntax
to limit the number of rows fetched (FIRST <n>) and start after
the beginning of the normal result set (SKIP <n>). The drawback
of SELECT FIRST <n> SKIP <n> FROM <whatever> is that the system has
to fetch all the results in <whatever> first, then give you the
subset. A query that fetches a 10,000 row results set with FIRST
SKIP getting 20 rows at a time actually gets and sorts 5,000,000
rows. A colossal waste of cycles.

Regards,


Ann