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

Restier pattern for AsNoTracking on get/read #726

Open
xsolon opened this issue May 19, 2023 · 6 comments
Open

Restier pattern for AsNoTracking on get/read #726

xsolon opened this issue May 19, 2023 · 6 comments
Milestone

Comments

@xsolon
Copy link

xsolon commented May 19, 2023

Is there a pattern to use AsNoTracking on Get requests?

@robertmclaws
Copy link
Collaborator

Hello! Great question. Can I ask at which point in the process? Maybe you can send a pseudo code example of what you're trying to accomplish?

Thanks!

@Tiberriver256
Copy link

I believe they are referring to this statement in the EFCore documentation:

No-tracking queries are useful when the results are used in a read-only scenario. They're generally quicker to execute because there's no need to set up the change tracking information. If the entities retrieved from the database don't need to be updated, then a no-tracking query should be used.

According to this guidance all OData GET requests should be AsNoTracking for best performance.

@robertmclaws
Copy link
Collaborator

Thanks for that @Tiberriver256 it's really interesting. @jspuij what do you think? I would imagine that doing this on the EF6 and EFC6+ side would speed up the results. Maybe it wouldn't be turned on for batches, but for any other GET it makes sense.

@xsolon
Copy link
Author

xsolon commented May 20, 2023 via email

@jspuij
Copy link
Contributor

jspuij commented May 22, 2023

@robertmclaws. I think it would be a useful addition. There is however another use for tracking. When tracking is on, with recursive queries (e.g expand a parent child relationship on the same entity), the context will detect the same instance and return actually the same entity. Otherwise it will happily recreate the entity from the DB results and you can have two entities pointing to the same record. I'm not sure whether this is relied upon by Restier (e.g. for detecting circular references) or maybe by some users inside the hook functions in their own descendant API. So at least I'd make it configurable. Question is whether we'd make it a global configuration or even more granular.

@xsolon
Copy link
Author

xsolon commented May 22, 2023 via email

@robertmclaws robertmclaws added this to the 1.1.1 milestone Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants