Skip to content

Commit

Permalink
Merge pull request #5268 from dlubitz/90/bugfix/performance-find-pare…
Browse files Browse the repository at this point in the history
…nt-node-aggregate

BUGFIX: Improve performance on find*Aggregates
  • Loading branch information
mhsdesign authored Oct 7, 2024
2 parents 2a18885 + 4f058e3 commit c14a159
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,9 @@ public function findNodeAggregateById(
public function findParentNodeAggregates(
NodeAggregateId $childNodeAggregateId
): NodeAggregates {
$queryBuilder = $this->nodeQueryBuilder->buildBasicNodeAggregateQuery()
->innerJoin('n', $this->nodeQueryBuilder->tableNames->hierarchyRelation(), 'ch', 'ch.parentnodeanchor = n.relationanchorpoint')
->innerJoin('ch', $this->nodeQueryBuilder->tableNames->node(), 'cn', 'cn.relationanchorpoint = ch.childnodeanchor')
->andWhere('ch.contentstreamid = :contentStreamId')
$queryBuilder = $this->nodeQueryBuilder->buildParentNodeAggregateQuery()
->innerJoin('h', $this->nodeQueryBuilder->tableNames->node(), 'cn', 'cn.relationanchorpoint = h.childnodeanchor')
->andWhere('h.contentstreamid = :contentStreamId')
->andWhere('cn.nodeaggregateid = :nodeAggregateId')
->setParameters([
'nodeAggregateId' => $childNodeAggregateId->value,
Expand Down
12 changes: 10 additions & 2 deletions Neos.ContentGraph.DoctrineDbalAdapter/src/NodeQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,10 @@ public function buildChildNodeAggregateQuery(NodeAggregateId $parentNodeAggregat
return $this->createQueryBuilder()
->select('cn.*, ch.contentstreamid, ch.subtreetags, cdsp.dimensionspacepoint AS covereddimensionspacepoint')
->from($this->tableNames->node(), 'pn')
->innerJoin('pn', $this->tableNames->hierarchyRelation(), 'ph', 'ph.childnodeanchor = pn.relationanchorpoint')
->innerJoin('pn', $this->tableNames->hierarchyRelation(), 'ch', 'ch.parentnodeanchor = pn.relationanchorpoint')
->innerJoin('ch', $this->tableNames->dimensionSpacePoints(), 'cdsp', 'cdsp.hash = ch.dimensionspacepointhash')
->innerJoin('ch', $this->tableNames->node(), 'cn', 'cn.relationanchorpoint = ch.childnodeanchor')
->where('pn.nodeaggregateid = :parentNodeAggregateId')
->andWhere('ph.contentstreamid = :contentStreamId')
->andWhere('ch.contentstreamid = :contentStreamId')
->orderBy('ch.position')
->setParameters([
Expand All @@ -70,6 +68,16 @@ public function buildChildNodeAggregateQuery(NodeAggregateId $parentNodeAggregat
]);
}

public function buildParentNodeAggregateQuery(): QueryBuilder
{
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')
->innerJoin('h', $this->tableNames->dimensionSpacePoints(), 'dsp', 'dsp.hash = h.dimensionspacepointhash')
->where('h.contentstreamid = :contentStreamId');
}

public function buildFindRootNodeAggregatesQuery(ContentStreamId $contentStreamId, FindRootNodeAggregatesFilter $filter): QueryBuilder
{
$queryBuilder = $this->buildBasicNodeAggregateQuery()
Expand Down

0 comments on commit c14a159

Please sign in to comment.