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

JSON/Query: improve de-duplication logic for collection element access scenarios #29606

Closed
maumar opened this issue Nov 18, 2022 · 2 comments
Closed
Assignees

Comments

@maumar
Copy link
Contributor

maumar commented Nov 18, 2022

Part (or continuation) of #28648 work.

Extracting out the de-duplication work which is going to be (mostly) complex work in shaper.
The idea is to detect cases where we already projected a given json entity and re-use it, rather than adding it to projection again.
Examples:

One = x.MyJosnCollection,
Two = x.MyJsonCollection[2]
One = x.MyJosnReference
Two = x.MyJosnReference.MyNestedJsonCollection[prm]

We do that for references already, but it's much harder for collections because we need to keep track of ordinal keys (which never change when we de-duplicate references only). Also, collection elements are generated in the body of IncludeJsonEntityCollection, so we don't have access to individual entities at compile time. Probably will need to use the resulting collections and access their required elements. We need to pay attention to ordering of things, so that we don't access the element in JSON collection before that collection has been populated. We could maybe use similar strategy as include does - store those expressions in separate list, so that when we construct the final block expression, those collection accesses come after.

Until this is done, all queries projecting JSON which accesses element in a collection must be set to no-tracking, even if the owner entity is also projected.

@roji
Copy link
Member

roji commented Nov 18, 2022

@maumar is this deduplication something we do in non-JSON cases (e.g. for owned collections or collection includes)?
For example:

One = x.MyNonJsonCollection
Two = x.MyNonJsonCollection.First()

@ajcvickers
Copy link
Contributor

Duplicate of #29513

@ajcvickers ajcvickers marked this as a duplicate of #29513 Nov 19, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Nov 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants