Skip to content

Fetch payload and vectors in scroll leaves only - #10384

Merged
timvisee merged 1 commit into
skip-redundant-id-resolutionfrom
skip-redundant-id-resolution-scroll-leaves
Sep 1, 2026
Merged

timvisee merged 1 commit into
skip-redundant-id-resolutionfrom
skip-redundant-id-resolution-scroll-leaves

Conversation

@generall

Copy link
Copy Markdown
Member

Fix for the integration-tests-consensus failure on #10333: test_payload_io_read_is_within_limit[query] reads 7229 B instead of < 300 B.

Why

root_plan_without_prefetches pushes with_payload/with_vector into the leaf for every no-rescore query. For a search leaf that ends up in Segment::search_batch, which hydrates every segment's local top-k before the merge — 50 segments × limit 10 = 500 payload reads for a 10-point result. This is the read amplification #6279 removed, and the test guards it.

Scroll leaves are different: internal_scroll_by_id / internal_scroll_by_field / scroll_randomly read ids (and order values) per segment, merge, take(limit), and only then call scroll_records once for the final page. Pushing the fetch down there costs nothing extra and keeps the redundant id resolution out.

Change

  • The leaf fetches only for scroll-type queries (None / OrderBy / Sample); Vector / Fusion / Formula / Mmr leaves stay bare and the root plan retrieves for the merged result, as before.
  • test_try_from_no_prefetch goes back to expecting a bare search leaf; the new MMR and scroll planner tests are unchanged.

Getting the same win for vector search would need internal offsets carried through the merge so the final points can be fetched without re-resolving — separate PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SUWh5PqUeSefrUqUwXxU3E

A search leaf hydrates every segment's local top-k before merging, so
`with_payload` there multiplies payload I/O by the segment count — the
regression #6279 fixed and `test_payload_io_read_is_within_limit[query]`
guards. Scroll leaves retrieve once for the merged page, so they keep
fetching directly; search leaves stay bare and the root plan retrieves
for the final result.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SUWh5PqUeSefrUqUwXxU3E
@generall
generall requested a review from timvisee August 29, 2026 22:12
@qdrant qdrant deleted a comment from coderabbitai Bot Sep 1, 2026

@timvisee timvisee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@timvisee
timvisee merged commit 3079f29 into skip-redundant-id-resolution Sep 1, 2026
16 checks passed
@timvisee
timvisee deleted the skip-redundant-id-resolution-scroll-leaves branch September 1, 2026 09:22
timvisee added a commit that referenced this pull request Sep 2, 2026
* perf: skip retrieval in scroll when no payload or vectors are requested

Every scroll variant went through SegmentsSearcher::retrieve to build its
records, even when neither payload nor vectors were asked for. That is a
has_point lookup per id per segment plus a version and id resolution per
hit, only to yield records holding nothing but the id. The universal query
API always scrolls this way and fetches payload separately afterwards.

Build the bare records from the ids directly in that case. The retrieve
could only have dropped ids deleted in between, which the update lock held
across the scroll rules out.

* perf: fetch payload and vectors in the leaf of plain query requests

A query without prefetches and without rescoring is served by a single
leaf search or scroll whose result is returned as is. The planner still
built that leaf without payload or vectors and filled them in afterwards
through SegmentsSearcher::retrieve, which resolves every result id in
every segment again: the same cost #10312 removed from the search API,
paid once more at the end of each query.

Let the leaf carry the requested payload and vectors instead, so the
segment attaches them to the results it already holds by offset, and
clear the root plan so the fill step is skipped. Prefetch leaves and
rescored roots (MMR) are unchanged. As with the search API, this fetches
payload for each segment's candidates rather than for the merged top
`limit` alone.

* Use new_empty function

* fix: fetch payload and vectors in scroll leaves only (#10384)

A search leaf hydrates every segment's local top-k before merging, so
`with_payload` there multiplies payload I/O by the segment count — the
regression #6279 fixed and `test_payload_io_read_is_within_limit[query]`
guards. Scroll leaves retrieve once for the merged page, so they keep
fetching directly; search leaves stay bare and the root plan retrieves
for the final result.


Claude-Session: https://claude.ai/code/session_01SUWh5PqUeSefrUqUwXxU3E

Co-authored-by: Claude Fable 5 <[email protected]>

---------

Co-authored-by: Andrey Vasnetsov <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>
timvisee added a commit that referenced this pull request Sep 3, 2026
* perf: skip retrieval in scroll when no payload or vectors are requested

Every scroll variant went through SegmentsSearcher::retrieve to build its
records, even when neither payload nor vectors were asked for. That is a
has_point lookup per id per segment plus a version and id resolution per
hit, only to yield records holding nothing but the id. The universal query
API always scrolls this way and fetches payload separately afterwards.

Build the bare records from the ids directly in that case. The retrieve
could only have dropped ids deleted in between, which the update lock held
across the scroll rules out.

* perf: fetch payload and vectors in the leaf of plain query requests

A query without prefetches and without rescoring is served by a single
leaf search or scroll whose result is returned as is. The planner still
built that leaf without payload or vectors and filled them in afterwards
through SegmentsSearcher::retrieve, which resolves every result id in
every segment again: the same cost #10312 removed from the search API,
paid once more at the end of each query.

Let the leaf carry the requested payload and vectors instead, so the
segment attaches them to the results it already holds by offset, and
clear the root plan so the fill step is skipped. Prefetch leaves and
rescored roots (MMR) are unchanged. As with the search API, this fetches
payload for each segment's candidates rather than for the merged top
`limit` alone.

* Use new_empty function

* fix: fetch payload and vectors in scroll leaves only (#10384)

A search leaf hydrates every segment's local top-k before merging, so
`with_payload` there multiplies payload I/O by the segment count — the
regression #6279 fixed and `test_payload_io_read_is_within_limit[query]`
guards. Scroll leaves retrieve once for the merged page, so they keep
fetching directly; search leaves stay bare and the root plan retrieves
for the final result.


Claude-Session: https://claude.ai/code/session_01SUWh5PqUeSefrUqUwXxU3E

Co-authored-by: Claude Fable 5 <[email protected]>

---------

Co-authored-by: Andrey Vasnetsov <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants