Repository navigation
Closed
Milestone
Description
Brain dump of potential refactorings in the query pipeline captured from a discussion today with @smitpatel and @maumar.
- [ ] Immutable SelectExpression via facade/visitors Not worth
- AliasExpressions everywhere or ColumnRefExpressions for referentially consistent SQL tree. (@smitpatel) Query: Refactor SelectExpression for referential integrity #7950
- Include via QueryModel (@anpete) Query: Include: Second part of new IncludeCompiler - Adds support for single level collection includes. #7974
- [ ] Include/nav-prop synergy via early QM rewrites.
- [ ] Immutable QueryModel
- [ ] First-class * expression (perhaps via exploded column containment idea)We do not have * projection for now. We can introduce it in future. - SearchConditionTranslatingVisitor rewrite (Query: Refactor SearchConditionTranslatingVisitor #7554)
- Subquery lifting at query model level (Query: Flatten out subquery models at query optimizer #7613)
- Consistentize use of visitors/extension nodes, VisitChildren etc.
- Apply CompositePredicateExpressionVisitor to other parts of the SelectExpression (Query: Apply optimizations to composite predicates in all parts of the query #7608)
- [ ] Evaluate ClientEval flags.We do not have client eval flag. - Investigate NullConditionalExpression processing in RequiresMaterializationExpressionVisitor (Query : investigate if its enough to visit AccessExpression of the NullConditionalExpression when looking for query sources requiring materialization #7746)
- clean up Nav + Entity Equality rewriting visitors (Query/Cleanup : Rewrite Navigation rewriter #7773)
- Clean up & Improve QueryOptimizer (Query: Optimize QueryOptimizer #7831)
- Avoid unnecessary pushdown of subqueries (Query: Improve how SelectExpression performs join to preserve sufficient metadata for binding #8094)
- [ ] Investigate DRYing up null expressions (NullableExpression and NullConditionalExpression)Removed NullableExpression
- [ ] Clean-up logic around RemoveConvert (Query: Clean-up logic around RemoveConvert #8318)Nomore RemoveConvert - Rename and clean-up EQMV.OptimizeQueryModel
- log contents of compiled code (Query/Logging: log contents of compiled code (e.g. materializers inside a shaper) as part of the query plan #9455)
@smitpatel, @maumar Feel free to add more detail here.
Activity
tuespetre commentedon Mar 7, 2017
How about the
RelationalEntityQueryableExpressionVisitorvsMemberAccessBindingExpressionVisitorthing? Not the fact that they are two separate visitors (they have different purposes) but the fact thatRelationalEntityQueryableExpressionVisitorseems to be overstepping its bounds by being responsible for adding things toSelectExpressions. I ask because as I am writing and fixing tests for some complexGroupByqueries, I'm seeing thatMemberAccessBindingExpressionVisitoris going to need to be able to bind grouping keys, which means they need to be present in theSelectExpression, which means there is going to have to be some duplicate grouping key processing logic going on between the two visitors as it stands.EDIT: Think I have something working for now that's not too awful but I'll leave these thoughts here anyways...
smitpatel commentedon Mar 28, 2017
TableExpressionBase Alias & QuerySource both are nullable & settable. Review.
Same for
PredicateJoinExpressionBasesmitpatel commentedon Mar 28, 2017
FromSqlExpression.Argumentsis not a collection property, justExpression. Review property name.smitpatel commentedon Mar 29, 2017
Eliminate
IsProjectStarby introducing an expression in SelectExpression.Projection representing star projection.tuespetre commentedon Apr 12, 2017
I have an idea to simplify/streamline a good chunk of code around shaped queries, parameter injection, and similar (possibly includes but I'm not up to speed on how that feature has been evolving.) Basically, represent all of these 'special method call expressions' as reducible extension expressions that carry appropriate metadata with them: for instance,
ShapedQueryExpression, which carries with it aSelectExpressionand aShaper, and whenReduce()is called, it reduces down to the appropriateMethodCallExpression.By doing this, the codebase can move away from a lot of the trickiness of digging into
MethodCallExpressionsto inspect their methods and arguments and perform surgery on them, and towards a more 'expressive' way that encapsulates that kind of logic in one place.I think the code will better explain itself so I will submit a PR to demonstrate the idea using
ShapedQueryExpression.anpete commentedon Apr 12, 2017
This sounds good. We have discussed changes like this internally, too. Look forward to the PR.
tuespetre commentedon Apr 14, 2017
More ideas for building a richer expression tree:
SqlTranslatingExpressionVisitorreturnnulland have aClientEvalPredicateproperty, have it return expressions that can be used with pattern matching for a more functional processing style:SqlTranslatableExpressionSqlUntranslatableExpressionSqlPartiallyTranslatableExpressionwithTranslatableExpressionandUntranslatableExpressionproperties to represent anAndAlsoexpression with a translatable side and an untranslatable sideEntityReferenceExpressionMappedPropertyExpressionUnmappedPropertyExpression7 remaining items
smitpatel commentedon Sep 1, 2018
Pulling this into 3.0 since we should either finish this with #12795 or close this.
smitpatel commentedon Jun 5, 2019
We have done whatever was relevant here in new pipeline. Closing as fixed.