Skip to content

Commit d64840a

Browse files
committed
Optimize BI Q5. Fixes ldbc#104
1 parent 8dd99b2 commit d64840a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

cypher/queries/bi-5.cypher

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
:param tag => 'Snowboard'
44
*/
55
MATCH (tag:Tag {name: $tag})<-[:HAS_TAG]-(message:Message)-[:HAS_CREATOR]->(person:Person)
6-
OPTIONAL MATCH (:Person)-[like:LIKES]->(message)
7-
OPTIONAL MATCH (message)<-[:REPLY_OF]-(comment:Comment)
8-
WITH person, count(DISTINCT like) AS likeCount, count(DISTINCT comment) AS replyCount, count(DISTINCT message) AS messageCount
6+
OPTIONAL MATCH (message)<-[likes:LIKES]-(:Person)
7+
WITH person, message, count(likes) AS likeCount
8+
OPTIONAL MATCH (message)<-[:REPLY_OF]-(reply:Comment)
9+
WITH person, message, likeCount, count(reply) AS replyCount
10+
WITH person, count(message) AS messageCount, sum(likeCount) AS likeCount, sum(replyCount) AS replyCount
911
RETURN
1012
person.id,
1113
replyCount,

0 commit comments

Comments
 (0)