Skip to main content

Pagination

Scalar queries use LIMIT/OFFSET; counts are separate:

SELECT * FROM book_vectors WHERE word_count > 0 LIMIT 10 OFFSET 10;
SELECT COUNT(*) FROM book_vectors WHERE word_count > 0;

dbVisitor Usage

Add a Page argument to a Mapper method. The entity mapping is shown in Entity Mapping.

@Query("SELECT * FROM book_vectors WHERE word_count > 0")
List<BookVector> findPage(Page page);
Page page = new PageObject(1, 10);
List<BookVector> rows = mapper.findPage(page);

Page numbering starts at zero. Page appends LIMIT/OFFSET, so omit existing pagination, a trailing semicolon, and WITH options. For queries with WITH, specify pagination in the command and do not pass Page.

Notes

Scalar ordering

Milvus does not provide scalar ORDER BY. Pages from separate requests are not a stable snapshot.

Page size and totals

Page controls the returned range; fetchSize controls internal fetches. KNN totals are not TopK counts; do not request automatic totals for vector-range queries. See SELECT.

Counts and page reads are separate requests; concurrent writes can change their results. See 9.5 Pagination for the common API.

Fluent Iteration

iteratorByBatch and iteratorForLimit issue separate LIMIT/OFFSET queries and release each result set after reading the page. They do not share a server snapshot; concurrent writes can affect later pages. A negative limit in iteratorForLimit means traversal without a total limit.

When repeatedly selecting and deleting a page of keys, read the first page each time. Increasing OFFSET after deletion can skip records.