-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add automatic SubQueries for performance in DQM
- Loading branch information
1 parent
8ab8940
commit b4922d0
Showing
8 changed files
with
1,754 additions
and
1,487 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
b4922d0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Faster queries using
@foreach
onWordTemplate
/EmailTemplate
WordTemplates
andEmailTemplates
are based in dynamic queries, this means that all the tokens defined in the template are going to be columns in a flat table.Example:
With the original query:
And the template
More or less produces que
QueryRequest
equivalent to thisFindOptions
Until this change, for each collection
Element
token like the one in@foreach[Entity.Contract.Element]
, the query needed to to make aSelectMany
(OUTER APPLY
in SQL).If you have one or two
@foreach
this is not a problem, but once you have 4 or 5@foreach
, specially from unrelated collections, you get an explosion of rows due to the orthogonal combination of results.To prevent this, now we try to replace the
SelectMany
by an automatic sub query.Note how the end result is the same flat table, but has been flattened in-memory.
This means that WordTemplates and EmailTemplates with many
@foreach
:Limitations
This optimization is made at the dynamic query level for any query that:
Element
Element
This is a exceptional case for
SearchControl
, but a very typical case forWordTemplate
/EmailTemplate
.Enjoy!