Simone Vellei
Simone Vellei

Reputation: 342

Neo4j Cypher Query performance

I've have a query for search elements similar to another, using tag concepts:

START similar=node:TYPE_INDEX("type1"), to=node(20325) 
match similar-[:TAGGED]->tag<-[:TAGGED]-to
return distinct similar, count(tag)
order by count(tag) DESC

"similar" is a set of node that are indexed using the type property. "To" is the node that I have to compare with "similar" nodes.

The similar query itself returns 500 nodes, and the count of relations TAGGED is 3000. Tag nodes are 500. On my machine this query takes 50secs.

Remove the order by clause and/or count clause not improve performance.

Upvotes: 1

Views: 1071

Answers (1)

Michael Hunger
Michael Hunger

Reputation: 41696

Which version of Neo4j are you using? How do you execute the query (REST, web-console, shell, java)? Is this the first run in the session or the second or third?

Can you try to rewrite your match clause, so that to comes first? It shouldn't make a difference but would be interesting to know.

match to-[:TAGGED]->tag<-[:TAGGED]-similar

Thanks a lot.

Upvotes: 0

Related Questions