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
This should avoid processing useless rows when we have relationship only
constraints.
This especially improves the IPAM use-case, where the uniqueness
constraint is the (address/prefix, namespace) tuple.
Without this change, the query would check for nodes having that same
address and fetch ALL nodes present in the same namespace.
With this change, the query is now FIRST checking nodes having that same
address and THEN checking if these previous nodes are in the same namespace.
Signed-off-by: Fatih Acar <[email protected]>
MATCH attr_path = (start_node:%(node_kind)s)-[:HAS_ATTRIBUTE]->(attr:Attribute)-[r:HAS_VALUE]->(attr_value:AttributeValue)
106
+
MATCH attr_path = (attr_start_node:%(node_kind)s)-[:HAS_ATTRIBUTE]->(attr:Attribute)-[r:HAS_VALUE]->(attr_value:AttributeValue)
107
107
WHERE attr.name in $attribute_names
108
108
AND ([attr.name, type(r)] in $attr_paths
109
109
OR (attr_value.value in $attr_values AND [attr.name, type(r), attr_value.value] in $attr_paths_with_value))
110
-
RETURN start_node, attr_path as potential_path, NULL as rel_identifier, attr.name as potential_attr, attr_value.value as potential_attr_value
111
110
"""% {"node_kind": self.query_request.kind}
112
111
113
112
relationship_attr_paths_with_value_subquery="""
114
-
MATCH rel_path = (start_node:%(node_kind)s)-[:IS_RELATED]-(relationship_node:Relationship)-[:IS_RELATED]-(related_n:Node)-[:HAS_ATTRIBUTE]->(rel_attr:Attribute)-[:HAS_VALUE]->(rel_attr_value:AttributeValue)
113
+
OPTIONAL MATCH rel_path = (attr_start_node:%(node_kind)s)-[:IS_RELATED]-(relationship_node:Relationship)-[:IS_RELATED]-(related_n:Node)-[:HAS_ATTRIBUTE]->(rel_attr:Attribute)-[:HAS_VALUE]->(rel_attr_value:AttributeValue)
115
114
WHERE relationship_node.name in $relationship_names
116
115
AND ([relationship_node.name, rel_attr.name] in $relationship_attr_paths
117
116
OR (rel_attr_value.value in $relationship_attr_values AND [relationship_node.name, rel_attr.name, rel_attr_value.value] in $relationship_attr_paths_with_value))
118
-
RETURN start_node, rel_path as potential_path, relationship_node.name as rel_identifier, rel_attr.name as potential_attr, rel_attr_value.value as potential_attr_value
119
-
"""% {"node_kind": self.query_request.kind}
117
+
"""% {"node_kind": self.query_request.kind}
120
118
121
119
relationship_only_attr_paths_subquery="""
122
-
MATCH rel_path = (start_node:%(node_kind)s)-[:IS_RELATED]-(relationship_node:Relationship)-[:IS_RELATED]-(related_n:Node)
120
+
OPTIONAL MATCH rel_path = (attr_start_node:%(node_kind)s)-[:IS_RELATED]-(relationship_node:Relationship)-[:IS_RELATED]-(related_n:Node)
123
121
WHERE %(rel_node_filter)s relationship_node.name in $relationship_only_attr_paths
124
-
RETURN start_node, rel_path as potential_path, relationship_node.name as rel_identifier, "id" as potential_attr, related_n.uuid as potential_attr_value
125
122
"""% {
126
123
"node_kind": self.query_request.kind,
127
124
"rel_node_filter": "related_n.uuid IN $relationship_only_attr_values AND "
128
125
ifrelationship_only_attr_values
129
126
else"",
130
127
}
131
128
129
+
attr_paths_filter_subquery="""
130
+
WITH attr_start_node, attr_path, attr, attr_value
131
+
RETURN attr_start_node AS start_node, attr_path AS potential_path, NULL as rel_identifier, attr.name as potential_attr, attr_value.value as potential_attr_value
WITH attr_start_node, rel_path, relationship_node, related_n, rel_attr, rel_attr_value
136
+
RETURN attr_start_node AS start_node, rel_path AS potential_path, relationship_node.name as rel_identifier, rel_attr.name as potential_attr, rel_attr_value.value as potential_attr_value
137
+
"""
138
+
139
+
relationship_only_attr_paths_filter_subquery="""
140
+
WITH attr_start_node, rel_path, relationship_node, related_n
141
+
RETURN attr_start_node AS start_node, rel_path as potential_path, relationship_node.name as rel_identifier, "id" as potential_attr, related_n.uuid as potential_attr_value
0 commit comments