feat: Compress HANA expand queries by reducing duplicated statements #383
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Concept
When constructing an
expand
query it is required to reference the parent query in the child query. This was originally prevented by storing the results into a table value, but when switching away from theDO BEGIN
syntax the queries where being duplicated into each child query. This change attempts to remove the query duplication by defining them inside theWITH
clause which allows the child queries to directly reference the parent query. This SHOULD allow for the SQL parser to parse less and SHOULD allow for the execution plan optimizer to easier recognize that the query is doing the same thing. The big danger is that the execution plan recognizes that the query is doing the same thing and results in the queries executing in sequence. Which might result in reverting the behavior back to before #342. So the hope is that this makes everything much better and faster. 🤞