Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize rights lookup in list requests #3304

Closed
htdvisser opened this issue Oct 1, 2020 · 0 comments · Fixed by #4732
Closed

Optimize rights lookup in list requests #3304

htdvisser opened this issue Oct 1, 2020 · 0 comments · Fixed by #4732
Assignees
Labels
c/identity server This is related to the Identity Server in progress We're working on it performance Something is slow or takes too much CPU/Memory/...
Milestone

Comments

@htdvisser
Copy link
Contributor

Summary

We should optimize the rights lookup in list requests to reduce the number of DB roundtrips.

See also https://github.com/TheThingsIndustries/lorawan-stack/issues/1393#issuecomment-683651932

What is already there? What do you see now?

The current implementation checks the rights of the caller for each result in a list request, to make sure we don't return fields the caller doesn't have access to. If uncached, each of these rights checks results in a database roundtrip.

What is missing? What do you want to see?

Instead, we should investigate if we can query the rights for the entire page in a single DB roundtrip.

Environment

v3.9

How do you propose to implement this?

  • Define a rights.BulkFetcher interface that is implemented by the IS's DB fetcher
  • Add rights.Preload(ctx context.Context, ids ...ttnpb.Identifiers) error

How do you propose to test this?

Use tracing to (no longer) see the many queries.

@htdvisser htdvisser added c/identity server This is related to the Identity Server performance Something is slow or takes too much CPU/Memory/... labels Oct 1, 2020
@htdvisser htdvisser added this to the Backlog milestone Oct 1, 2020
@htdvisser htdvisser self-assigned this Oct 1, 2020
@htdvisser htdvisser modified the milestones: Backlog, 2021 Q3 Mar 31, 2021
@htdvisser htdvisser modified the milestones: 2021 Q3, v3.15.2 Sep 23, 2021
@htdvisser htdvisser added the in progress We're working on it label Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/identity server This is related to the Identity Server in progress We're working on it performance Something is slow or takes too much CPU/Memory/...
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant