-
-
Notifications
You must be signed in to change notification settings - Fork 223
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
BUGFIX: Improve performance on find*Aggregates #5268
BUGFIX: Improve performance on find*Aggregates #5268
Conversation
Sadly there are no test for |
But they are tested within the behat tests. If you mess up there, a lot of tests are failing. |
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.
I think this is correct, but I'd love @nezaniel to have a second look over it :)
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.
Amazing, thank you!
It seems we found the culprit. The reason for this obsolete join is history. Originally the nodename was stored in the hierarchy relation table. And with #5018 as stated:
The node name is now in the node table. There are actually more hidden places that can seemingly be optimised we found at least 4 places where a
|
This seems to be a bit more complex than expected. I need to check if the tests are covering all cases and if the changes still make sence. |
eaaf7e7
to
4f058e3
Compare
I've splitted the changes. This PR now only contains the first change I did. This only affects the NodeAggregates query, which we can safely improve, as they don't join subtree tags. The other changes are now in a draft PR #5273. I need to find a way to test these queries, especially the resulting subtree tags. As it makes a difference for subtree tags if I use the parentanchorpoint or the childanchorpoint to join the node data. |
return $this->createQueryBuilder() | ||
->select('n.*, h.contentstreamid, h.subtreetags, dsp.dimensionspacepoint AS covereddimensionspacepoint') | ||
->from($this->tableNames->node(), 'n') | ||
->innerJoin('n', $this->tableNames->hierarchyRelation(), 'h', 'h.parentnodeanchor = n.relationanchorpoint') |
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.
fyi the only difference to the previously used buildBasicNodeAggregateQuery
is that we join on h.parentnodeanchor
instead of h.childnodeanchor
I had the feeling introducing this might deduplicate code another place and it could:
In findParentNodeAggregateByChildOriginDimensionSpacePoint
we use the same logic besides one additional where
. So i think it could be nicely deduplicated like:
public function findParentNodeAggregateByChildOriginDimensionSpacePoint(NodeAggregateId $childNodeAggregateId, OriginDimensionSpacePoint $childOriginDimensionSpacePoint): ?NodeAggregate
{
$subQueryBuilder = ...;
$queryBuilder = $this->nodeQueryBuilder->buildParentNodeAggregateQuery()
->andWhere('n.nodeaggregateid = (' . $subQueryBuilder->getSQL() . ')')
->setParameters([
'contentStreamId' => $this->contentStreamId->value,
'childNodeAggregateId' => $childNodeAggregateId->value,
'childOriginDimensionSpacePointHash' => $childOriginDimensionSpacePoint->hash,
]);
Also i dont exactly understand how this utility is supposed to work (when do we pass arguments or when to use setParameters
) but because we dont return a final query i think its buildBasicParentNodeAggregateQuery
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.
Is your comment only for clarification? Or do you complain about the partially duplication of the queries and want to get that changed?
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.
i was just thoroughly reviewing this and partly investigating and trying to understand. So i guess 50/50 ill create a followup pr :D
_> #5276
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.
By reading, thanks for the effort and also trying to improve the other queries (after me sidetracking you into that idea which turned out to be more complex^^)
The queries to determine the child or parent aggregates have been joined the hierarchy relation (hr) twice. Once for the parent and once for the children. But the hr does contain already both anchorpoints, so a second join is not needed.
Replay without this change:
Replay with this change:
Fixes: #5269