storage-query-datafusion: narrow scan for unscoped service_key (#4727)#4731
Open
tillrohrmann wants to merge 1 commit into
Open
storage-query-datafusion: narrow scan for unscoped service_key (#4727)#4731tillrohrmann wants to merge 1 commit into
tillrohrmann wants to merge 1 commit into
Conversation
…tedev#4727) PR restatedev#4726 dropped the `service_key` partition-key extractor from the `state` and `sys_promise` tables because scoped rows for the same service_key are sharded under `hash(scope)` rather than `hash(service_key)`. The unconditional fallback to a full partition-key range scan is a noticeable regression for unscoped lookups vs. v1.6. Recover the optimization by gating it on an explicit `scope IS NULL` conjunct: when the user has already promised, via the filter, that scoped rows aren't of interest, narrowing to `hash(service_key)` is safe. The two extractors needed by `state` / `sys_promise` (scope-based and service_key-when-null) are bundled into a single builder `with_scope_or_service_key(scope_column, service_key_column)` so the call site reads as the dispatch it actually performs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> This fixes restatedev#4727.
Contributor
Author
|
@nikrooz the optimization only works if we add the |
Contributor
|
@tillrohrmann thanks. do you mean I should add |
igalshilman
approved these changes
May 13, 2026
Contributor
igalshilman
left a comment
There was a problem hiding this comment.
@tillrohrmann thanks for the fast turnaround, LGTM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR #4726 dropped the
service_keypartition-key extractor from thestateandsys_promisetables because scoped rows for the same service_key are sharded underhash(scope)rather thanhash(service_key). The unconditional fallback to a full partition-key range scan is a noticeable regression for unscoped lookups vs. v1.6.Recover the optimization by gating it on an explicit
scope IS NULLconjunct: when the user has already promised, via the filter, that scoped rows aren't of interest, narrowing tohash(service_key)is safe. The two extractors needed bystate/sys_promise(scope-based and service_key-when-null) are bundled into a single builderwith_scope_or_service_key(scope_column, service_key_column)so the call site reads as the dispatch it actually performs.This fixes #4727.