You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MATCH (parent1:`Parent1`:`BaseNode`) WITH collect(elementId(parent1)) AS __sn__ RETURN __sn__
MATCH (parent1:`Parent1`:`BaseNode`) OPTIONAL MATCH (parent1)-[__sr__:`Parent1_CONTAIN`]->(__srn__:`BaseNode`) WITH collect(elementId(parent1)) AS __sn__, collect(elementId(__srn__)) AS __srn__, collect(elementId(__sr__)) AS __sr__ RETURN __sn__, __srn__, __sr__
MATCH (baseNode:`BaseNode`) WHERE elementId(baseNode) IN $__ids__ OPTIONAL MATCH (baseNode)-[__sr__:`Parent2_CONTAIN`]->(__srn__:`BaseNode`) WITH collect(elementId(baseNode)) AS __sn__, collect(elementId(__srn__)) AS __srn__, collect(elementId(__sr__)) AS __sr__ RETURN __sn__, __srn__, __sr__
MATCH (baseNode:`BaseNode`) WHERE elementId(baseNode) IN $__ids__ OPTIONAL MATCH (baseNode)-[__sr__:`Parent1_CONTAIN`]->(__srn__:`BaseNode`) WITH collect(elementId(baseNode)) AS __sn__, collect(elementId(__srn__)) AS __srn__, collect(elementId(__sr__)) AS __sr__ RETURN __sn__, __srn__, __sr__
MATCH (rootNodeIds:`Parent1`) WHERE elementId(rootNodeIds) IN $rootNodeIds WITH collect(rootNodeIds) AS n OPTIONAL MATCH ()-[relationshipIds]-() WHERE elementId(relationshipIds) IN $relationshipIds WITH n, collect(DISTINCT relationshipIds) AS __sr__ OPTIONAL MATCH (relatedNodeIds) WHERE elementId(relatedNodeIds) IN $relatedNodeIds WITH n, __sr__ AS __sr__, collect(DISTINCT relatedNodeIds) AS __srn__ UNWIND n AS rootNodeIds WITH rootNodeIds AS parent1, __sr__, __srn__ RETURN parent1 AS __sn__, __sr__, __srn__
In the query log, shows it search for Parent2_CONTAIN but it shouldn't, because Parent2_CONTAIN is not in Parent1 node.
In real case, if I have 10 node extends the base node, it will end up query all 10 node's relationship, I think it is a performance issue.
Change to Child still have this issue
@Relationship(type = "Parent1_CONTAIN", direction = Relationship.Direction.OUTGOING)
privateList<BaseRelationship<Child>> parent1Relationships;
abccbaandy
changed the title
Generic relationship does not honor type when query
[Performance Issue] Generic relationship does not honor type when query
Aug 20, 2024
The person1Repository will query for :Parent1_CONTAIN nodes defined by parent1Relationships in Parent1.
Those relationships are of type BaseNode. The next iteration will than query for :Parent2_CONTAIN and :Parent1_CONTAIN defined in Parent2 and Parent1 as the implementations of BaseNode.
This behaviour is expected.
Looking at the other issue and the Child typed relationship, the same behaviour applies because the type definition is derived from the class public class BaseDbRelationship<T extends BaseNode> itself which is again "just" a BaseNode.
The person1Repository will query for :Parent1_CONTAIN nodes defined by parent1Relationships in Parent1. Those relationships are of type BaseNode. The next iteration will than query for :Parent2_CONTAIN and :Parent1_CONTAIN defined in Parent2 and Parent1 as the implementations of BaseNode. This behaviour is expected.
Looking at the other issue and the Child typed relationship, the same behaviour applies because the type definition is derived from the class public class BaseDbRelationship<T extends BaseNode> itself which is again "just" a BaseNode.
I can guess this behavior, but I think the design is wrong.
When I query parent1, SDN should search for Parent1_CONTAIN relationship only.
But I think the root cause is SDN treat the BaseNode as a Node.
In my domain, I don't really use the BaseNode, it just a base class for share common field and polymorphism.
In real case, I have many childes with same relationship type:
I have some node
When I get parent1 with find all:
The log shows
In the query log, shows it search for
Parent2_CONTAIN
but it shouldn't, becauseParent2_CONTAIN
is not in Parent1 node.In real case, if I have 10 node extends the base node, it will end up query all 10 node's relationship, I think it is a performance issue.
Change to
Child
still have this issueAlso, I think this issue is associate
#2933
The text was updated successfully, but these errors were encountered: