CursorPagination limitations regarding non-sequential data access
0 reputation · 14 Feb 2025, 15:52 UTC
Django Rest Framework provides CursorPagination to mitigate the performance degradation and data drift issues common with offset-based methods. While this approach ensures consistent results by using a unique ordering pointer, it inherently restricts the client to sequential navigation via next and previous page keys.
The current implementation does not support jumping to a specific page number or offset (e.g., ?page=50), which is a standard feature in PageNumberPagination. This creates a constraint for API consumers who require deep-linking or navigation to specific segments of a large dataset.
Can the CursorPagination class be extended to support arbitrary page jumps without sacrificing the performance benefits of the cursor mechanism? Is there a documented strategy to implement random-access pagination while maintaining the atomicity provided by cursors?