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

Precompiled queries: pre-generate SQL (2nd part of the query pipeline) #29753

Closed
roji opened this issue Dec 4, 2022 · 2 comments · Fixed by #33510
Closed

Precompiled queries: pre-generate SQL (2nd part of the query pipeline) #29753

roji opened this issue Dec 4, 2022 · 2 comments · Fixed by #33510

Comments

@roji
Copy link
Member

roji commented Dec 4, 2022

Once we can AOT-precompile the materializer (1st part of the query pipeline, #25009), we can also pregenerate final SQL (2nd part of the query pipeline).

  • The main design question here is to decide when/how much to precompile. This part of the query pipeline caches on the nullability of the parameters (since null/non-null results in different SQL), so the number of SQLs we'd need to generate grows exponentially with the number of parameters. It probably makes sense to choose an arbitrary (possibly tweakable) threshold for the number of parameters to avoid this explosion.
  • To reduce the permutations, our AOT infrastructure can examine the nullability of the parameters (i.e. captured variables) being referenced; a non-nullable parameter requires only a single SQL, not two. For reference types, the Roslyn symbol should be able to tell us whether the local variable being referenced is nullable or not.
  • In any case, we're most likely going to need to keep this part of the query pipeline at runtime. This is both because of the permutation explosion described above, and also because we sometimes generate SQL that isn't cachable (e.g. constantization of array.Contains()).
@glen-84

This comment was marked as resolved.

@roji roji changed the title AOT precompiled queries: pre-generate SQL (2st part of the query pipeline) AOT precompiled queries: pre-generate SQL (2nd part of the query pipeline) Feb 21, 2023
@roji

This comment was marked as resolved.

@roji roji added the area-perf label Jan 5, 2024
@roji roji changed the title AOT precompiled queries: pre-generate SQL (2nd part of the query pipeline) Precompiled queries: pre-generate SQL (2nd part of the query pipeline) Jan 5, 2024
@roji roji modified the milestones: Backlog, 9.0.0 Mar 21, 2024
roji added a commit to roji/efcore that referenced this issue Apr 10, 2024
roji added a commit to roji/efcore that referenced this issue Apr 10, 2024
roji added a commit to roji/efcore that referenced this issue Apr 10, 2024
roji added a commit to roji/efcore that referenced this issue Apr 11, 2024
roji added a commit to roji/efcore that referenced this issue Apr 11, 2024
roji added a commit to roji/efcore that referenced this issue Apr 11, 2024
roji added a commit to roji/efcore that referenced this issue Apr 30, 2024
roji added a commit to roji/efcore that referenced this issue May 3, 2024
roji added a commit that referenced this issue May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants