Search code examples
odata

What's the best practice to do "stable paging" in OData?


In the comment of this post (Problem with WCF Data Service (OData), SetEntitySetPageSize and custom operations), it mentioned “OData stable paging”.

I am quite new to OData, and trying to get stable paging in OData query.

By "stable paging", I mean there is an OData database in which new entries are constantly being created, I wanted the paging are not interrupted by the new data creation in the database.

For example, if I get the first page by $top=100, then get second page by $top=100&$skip=100, then the third page by $top=100&$skip=200, in which page size is 100. However, because the database is changing, the data I have skipped may not necessarily be the same data I retrieved from previous requests.

Just like the graph example shows data sorting by entry creation time, the first request and the second request:

enter image description here

I wonder what's the best way to do "Stable Paging"?

Thanks!


Solution

  • My current solution follows this post's recommendation - "Paging Through Results" by Markus Winand:

    http://use-the-index-luke.com/sql/partial-results/fetch-next-page

    It discussed general solutions to stable paging, although it's not OData specific, it works for my scenario.