Subject | Re: How to implement "fetch data on demand" at SQL level |
---|---|
Author | mailmur |
Post date | 2004-12-20T20:05:40Z |
> I have a 20 rows grid that I just want to implement "fetch data ondemand" 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,If you can find a meaninful sorted keyvalue then you might optimize
> 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
fetchOnDemand queries. Say, you have a customerId then you can fetch
next page with "select FIRST <n> ...where custid >
@LastCustIdFromPrevFetch.. Order By custid" style queries. This only
works if grid displayes data sorted by custId.
If I am right, then db does not fullscann the entire table even if you
are to fetch 64th page.