Database Reference
In-Depth Information
Since we want to display pages of three, we should try to fetch more results before dis-
playing this page to the user. Knowing that we've reached the end of bob 's partition, let's
see if we can find two more results in partitions that are situated after bob 's:
SELECT * FROM "user_status_updates"
WHERE TOKEN("username") > TOKEN('bob')
LIMIT 2;
By asking for usernames whose partition token is greater than bob 's token, we guarantee
that we get back results we haven't seen yet. The rows returned are the first two in
alice 's status updates:
Since we requested two rows and retrieved two rows, we know that there might be more
rows in alice 's partition. Once again, we ask for id values greater than the last one that
we saw in alice 's status updates:
SELECT * FROM "user_status_updates"
WHERE "username" = 'alice'
AND id > 3f9b5f00-e8f7-11e3-9211-5f98e903bf02
LIMIT 3;
The query returns two remaining status updates for alice :
Since we asked for three rows and only got back two, we know that we've now seen all
the status updates in alice 's partition. Now, we should check if there are any more parti-
tions to iterate over; we'll just ask for one, since we already have the first two rows of this
page:
Search WWH ::




Custom Search