Skip to content

OfflineFirstGetPolicy alwaysHydrate is unexpectedly slow #568

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

Open
TillJohanndeiter opened this issue Mar 22, 2025 · 2 comments · May be fixed by #569
Open

OfflineFirstGetPolicy alwaysHydrate is unexpectedly slow #568

TillJohanndeiter opened this issue Mar 22, 2025 · 2 comments · May be fixed by #569

Comments

@TillJohanndeiter
Copy link

I had some performance problems and tried out alwaysHydrate, awaitRemote and awaitRemoteWhenNoneExist. As expected awaitRemoteWhenNoneExist was the fastest policy. But alwaysHydrate seems to be slow like awaitRemote.

According to the doc

  /// This hydration is unawaited and is not guaranteed to complete before results are returned.
  /// This can be expensive to perform for some queries; see [awaitRemoteWhenNoneExist]
  /// for a more performant option or [awaitRemote] to await the hydration before returning results.

If the hydration is not awaited then i don't understand why i don't get any speedup. I expected that the local results are returned fast and that i get the updated data with a small delays.

@TillJohanndeiter
Copy link
Author

After i looked in the code i have an idea where the bottleneck could be. The problem occurred only with models that have multiple associations. If i use alwaysHydrate then all associations and associations of associations are fetched with alwaysHydrate. In my case this is not required. I would like to use awaitRemoteWhenNoneExist for them. I would like to create a PR to add a parameter like policyForAssociations to the get and subscribe method.

@richard457
Copy link

Noticed the same behaviour as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants