The recommended pattern for this kind of thing has always been to get the list of keys via the initial query, and then use getAll with whatever length list of keys you want iteratively as needed.
Querying GemFire records from 1000-th to 1010-th
Is there any pagination functionality in GemFire OQL ?
For example, there is a huge number of entries in some region.
Can we do a query from the client “get 10 entries starting from 1000 to 1010” ? We need this in Web GUI to show entries by pages.
So that only these 10 records are transferred from GemFire server to the client?
It was a discussion 3 years ago saying that this is not supported:
Has anything changed since that time?
Please sign in to leave a comment.
Michael, what if there are millions of keys in GemFire, and we need to display 10 records from 50 000 000 to 50 000 010 ?
Do we have to load all these 50 000 010 keys into a client, just to display 10 records out of these 50 000 010?
No you don't need to get all the keys. Do an OQL query to select for the keys you care about. select keys where some_predicate_is_true. Then use getall(keys) in chunks of keys that suit your needs for display.
For example, in gfsh I've created the following entries:
gfsh>put --key=d --value=cc --region=test
gfsh>put --key=c --value=cc --region=test
gfsh>put --key=b --value=bb --region=test
gfsh>put --key=a --value=aa --region=test
How can I get 2 entries starting from second entry of the list ordered by key?
I expect to get the following result:
Could you please provide the OQL string for gfsh for this particular example?
I understand what you are trying to do. Display the first 100 returned from a query followed by the next 100 when the user pages down, etc.
As I answered earlier, the best way that I can think of to do it is to Select keys (not values) based on a where clause that finds all of what you want and orders it then using getall(first_100_keys_in_list) to get the first batch, getall(second_100_keys_in_list) to get the second batch etc.
There is no way using only OQL to get the job done as far as I know.