Cezar Sas
Cezar Sas

Reputation: 306

Timetree specific nodes in range

I'm having difficulties to get all nodes in a specific time range. I have two types of node attached to the timetree, Nodes Tweet and Nodes News.

I want all the Tweets nodes. I'm using this query (10+ min stopped):

CALL ga.timetree.events.range({start: 148029120000, end: 1480896000000, relationshipType: "LAST_UPDATE", resolution: 'DAY'}) 
YIELD node
MATCH (a:TwitterUser)-[:POSTS]->(:Tweet)-[r:RETWEETS]->(:Tweet)<-[:POSTS]-(m:TwitterUser) 
RETURN id(a), id(m), count(r) AS NumRetweets 
ORDER BY NumRetweets DESC

But this takes a lot compared to the simple query (8 seconds):

MATCH (a:TwitterUser)-[:POSTS]->(:Tweet)-[r:RETWEETS]->(:Tweet)<-[:POSTS]-(m:TwitterUser) 
RETURN id(a), id(m), count(r) AS NumRetweets 
ORDER BY NumRetweets DESC

Actually, with my data, the 2 query should return the same nodes, so i dont understand the big time difference.

Upvotes: 0

Views: 274

Answers (1)

InverseFalcon
InverseFalcon

Reputation: 30397

The problem with your first query is that you're not doing anything with the results of the timetree query. It is literally just wasting cycles and bloating up the built up rows with data that's not even used.

You need to take the :Tweet nodes returned from your timetree query and include them into the next part of your query.

CALL ga.timetree.events.range({start: 148029120000, end: 1480896000000, relationshipType: "LAST_UPDATE", resolution: 'DAY'}) 
YIELD node
WITH node as tweet
WHERE tweet:Tweet
MATCH (a:TwitterUser)-[:POSTS]->(:Tweet)-[r:RETWEETS]->(tweet)<-[:POSTS]-(m:TwitterUser) 
RETURN id(a), id(m), count(r) AS NumRetweets 
ORDER BY NumRetweets DESC

Upvotes: 2

Related Questions