I am well aware of real-time database querying limitation, but I thought might seek help from others, basically what I'm trying to do is paginate the search result of a query, let's say we search for users with the name "motahir" and we have 100 results, I want to show the first 20 results and when the user scrolls down then retrieve the second 20 results, one possible trick is to download the whole results (all 100 records) and show only 20 and then add the rest of the result as the user scrolls down but this is inefficient, another trick is to limit the results to first 20 and when we want the next 20 records, we run a query to retrieve the first 40 records, the first 20 records of the 40 records that we've retrieved are duplicate, again this is inefficient, we'll have to download the previous set of data every time we want to retrieve a new 20 records.
it won't be a good idea to download the whole records as well, what if we had 1000 records with the name "motahir".
so any ideas of how to solve this problem?