Reputation: 33
The next query in a large database takes almost a minute.
MATCH (p1:Politician)-[r1:mentioned_by]->(c:Channel {name: "TN"})<-[r2:mentioned_by {video_id: r1.video_id}]-(p2:Politician)
WHERE p1.fullname < p2.fullname
WITH DISTINCT p1.fullname AS x, p2.fullname AS y
RETURN COUNT(*) AS rows
I have added an index over the name property from the Channel nodes and saved with that at least 10 seconds, but all in all the query takes like 50 seconds which is a lot. Any suggestion over which index to create?
Upvotes: 0
Views: 20
Reputation: 5385
One of the reasons that your query takes time may be the fact that you are comparing properties, which requires ‘opening’ many nodes. Apparently you assume that fullName is not a unique identifier. Otherwise I would create a unique constraint on that property and compare p1 to p2
Upvotes: 1