Skip to content

Skip redundant ID resolutions - #10333

Merged
timvisee merged 4 commits into
devfrom
skip-redundant-id-resolution
Sep 2, 2026
Merged

timvisee merged 4 commits into
devfrom
skip-redundant-id-resolution

Conversation

@timvisee

@timvisee timvisee commented Aug 25, 2026 •

Copy link
Copy Markdown
Member

Follow up of #10312

Follows the spirit of removing redundant ID look-ups, but in other places.

Primarily prevents a retrieve call in cases where we don't have to retrieve anything.

I wanted to apply a similar change to retrieve_over. It resolves IDs three times and is a building block for many APIs. For example, it first resolves point IDs and versions, then it resolves again when actually retrieving. But removing this first step breaks deduplication. And so I decided not to bother with it.

I did not benchmark this. But it assumes less work is cheaper.

I'd recommend to review this per commit.

All Submissions:

  • My PR targets the dev branch (not master) and my branch was created from dev.
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you formatted your code locally using cargo +nightly fmt --all command prior to submission?
  3. Have you checked your code using cargo clippy --workspace --all-features command?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@timvisee
timvisee requested review from agourlay and ffuugoo August 25, 2026 14:09
coderabbitai[bot]

This comment was marked as low quality.

@qdrant qdrant deleted a comment from coderabbitai Bot Aug 25, 2026
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.
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.
@timvisee
timvisee force-pushed the skip-redundant-id-resolution branch from 776031b to 4a39349 Compare August 28, 2026 11:52
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]>
@timvisee
timvisee requested a review from generall September 1, 2026 09:22
@qdrant qdrant deleted a comment from coderabbitai Bot Sep 1, 2026
@timvisee
timvisee merged commit ae0b075 into dev Sep 2, 2026
22 of 23 checks passed
@timvisee
timvisee deleted the skip-redundant-id-resolution branch September 2, 2026 08:03
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]>
@timvisee timvisee mentioned this pull request Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants