
Cursor-Based Pagination
A pagination technique for efficiently scrolling through large vector database result sets using cursors instead of offsets. Essential for retrieving all vectors in a collection or iterating through search results without performance degradation.
About this tool
Overview
Cursor-based pagination (also called scroll or continuation tokens) efficiently retrieves large result sets from vector databases by using cursors that mark position, avoiding the performance issues of offset-based pagination.
The Problem with Offsets
Offset-Based Pagination
SELECT * FROM vectors LIMIT 100 OFFSET 10000
Issues:
- Database must skip 10,000 rows each time
- Gets slower as offset increases
- Inconsistent results if data changes
- O(offset) complexity
Cursor-Based Solution
How It Works
- Request first page
- Database returns results + cursor (pointer to next position)
- Use cursor to get next page
- Repeat until no more results
Example
# Qdrant
cursor = None
all_points = []
while True:
result = client.scroll(
collection_name="my_collection",
limit=100,
offset=cursor
)
all_points.extend(result[0]) # Points
cursor = result[1] # Next cursor
if cursor is None: # No more results
break
Benefits
- Constant Performance: O(1) regardless of position
- Consistent Results: Snapshot isolation
- Efficient: No redundant work
- Scalable: Works with millions of records
Use Cases
- Exporting entire collections
- Batch processing all vectors
- Data migration
- Full dataset iteration
- Background sync jobs
Best Practices
- Reasonable Page Sizes: 100-1000 items
- Timeout Handling: Cursors may expire
- Progress Tracking: Log cursor values
- Error Recovery: Store last successful cursor
Database Support
- Qdrant: scroll() with offset parameter
- Milvus: query iterator
- Weaviate: cursor in GraphQL
- Pinecone: pagination tokens
- Elasticsearch: scroll API
Pricing
Not applicable (query pattern/technique).
Surveys
Loading more......
Information
Websiteqdrant.tech
PublishedMar 15, 2026
Categories
Tags
Similar Products
6 result(s)