Skip to content

Conversation

@josephschorr
Copy link
Member

This should ensure that, for recognized query shapes, the best index and sort order is selected for ReadRels

Testing

Unit, datatstore and steelthread tests

@josephschorr josephschorr requested a review from a team as a code owner October 21, 2025 20:03
@github-actions github-actions bot added area/api v1 Affects the v1 API area/datastore Affects the storage system area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) labels Oct 21, 2025
@codecov
Copy link

codecov bot commented Oct 21, 2025

Codecov Report

❌ Patch coverage is 60.46512% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.15%. Comparing base (9029960) to head (45bdbf6).

Files with missing lines Patch % Lines
internal/datastore/common/sql.go 37.50% 3 Missing and 2 partials ⚠️
internal/datastore/crdb/reader.go 33.34% 2 Missing and 2 partials ⚠️
internal/datastore/crdb/schema/forcedindex.go 0.00% 2 Missing ⚠️
internal/datastore/crdb/schema/indexes.go 88.89% 1 Missing and 1 partial ⚠️
internal/datastore/postgres/schema/indexes.go 0.00% 2 Missing ⚠️
internal/datastore/spanner/indexes.go 0.00% 2 Missing ⚠️

❌ Your project check has failed because the head coverage (59.15%) is below the target coverage (75.00%). You can increase the head coverage or adjust the target coverage.

❗ There is a different number of reports uploaded between BASE (9029960) and HEAD (45bdbf6). Click for more details.

HEAD has 21 uploads less than BASE
Flag BASE (9029960) HEAD (45bdbf6)
47 26
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2632       +/-   ##
===========================================
- Coverage   79.52%   59.15%   -20.36%     
===========================================
  Files         454      412       -42     
  Lines       47138    43740     -3398     
===========================================
- Hits        37481    25870    -11611     
- Misses       6894    15369     +8475     
+ Partials     2763     2501      -262     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@miparnisari miparnisari self-assigned this Oct 27, 2025
Copy link
Contributor

@miparnisari miparnisari left a comment

Choose a reason for hiding this comment

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

Shall we rename this PR from feat: ... to perf: ... since it's not a new feature but rather a performance improvement?

BySubject

// ChooseEfficient lets the datastore choose the most efficient order based on the query shape and available indexes.
ChooseEfficient
Copy link
Contributor

Choose a reason for hiding this comment

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

why give the caller a new option, when unsorted: lets the underlying datastore choose the order exists? or should we update unsorted to just say no order at all?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because sometimes the caller knows better and letting it choose is important in those instances

ds,
dsFilter,
pageSize,
options.ByResource,
Copy link
Contributor

Choose a reason for hiding this comment

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

By reading https://buf.build/authzed/api/docs/main:authzed.api.v1#authzed.api.v1.PermissionsService.ReadRelationships it doesn't seem that we ever promised a particular return order. I'm curious why this code was the way it is with options.ByResource? was this an undocumented feature or just an accident?

can we update the API to be explicit that callers shouldn't expect any order?

Copy link
Member Author

Choose a reason for hiding this comment

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

Its necessary for cursoring; we need some stable order in order to cursor

Copy link
Contributor

Choose a reason for hiding this comment

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

ok; should we update the API docs to say something like "the results will be sorted but the order will depend on the filter passed"?

This should ensure that, for recognized query shapes, the best index and sort order is selected for ReadRels
@josephschorr josephschorr changed the title feat: Have read relationships use dynamic index forcing perf: Have read relationships use dynamic index forcing Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api v1 Affects the v1 API area/datastore Affects the storage system area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants