are you paginating for a user browsing results, or to chunk up some batch job, or other?
do you need sorting before pagination?
can you split work on known-in-advance split values, or do you want the “next n”?
do you need arbitrary query power, or just to walk an attribute?
Then there are number of capabilities you might use:
index-pull is fully incremental and sorts by an index. q/qseq does not (yet) have sorting, but has arbitrary query power. q/qseq with range predicates uses indexes to avoid considering values outside the requested range.
My use case is for a UI sorted table. It’s sent via graphql but the transport doesn’t really matter here. It need to be sorted, then paged, then hydrated (pull). As with most UI tables, it will need runtime provided where conditions. I believe this is a pretty common UI requirement. It would be the same if the UI was infinite scroll vs classic paging.
Today I do this with:
a sorted datalog query (sort field and id only)
drop n, take n
run N pulls for the page of records (could alternatively be a second query)
The core constraint is the sorted first step. I’m hoping there’s now a better way to do this.
My current solution could become a problem if the dataset becomes large because it will effectively be a full scan to find/sort the results.
that was my thought but I don’t think this supports the runtime filtering i.e. add extra where clauses at runtime based on user input.
my current use-case is a table that allows filtering based on first (few) letters of a column. in future I’m sure I will need different filters, hence the more general question.
Thanks Stu. I’ll give it a try for that requirement.
Is it correct to say that there is no solution for sorted pagination for queries with arbitrary where conditions? I also need more complex filters for my lists e.g. entities matching N different clauses, all configured by the user at runtime, not using string prefixes.
For this I believe we still need to use the old (non-lazy) design but I’ll be delighted to be corrected.
I need pagination to chunk some batch jobs, where each chunk must run once or twice per day.
At this time I am sorting by id and then calling drop + take but it would be great if I didn’t have to sort the results in order to ensure I don’t process an element more than once.