Neo4j Cypher 查询性能
我使用标签概念查询与另一个相似的搜索元素:
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
“相似”是使用 type 属性索引的一组节点。 “To”是我必须与“相似”节点进行比较的节点。
类似查询本身返回500个节点,TAGGED的关系计数为3000。标签节点为500。 在我的机器上这个查询需要 50 秒。
删除 order by 子句和/或 count 子句不会提高性能。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用的是哪个版本的 Neo4j?如何执行查询(REST、Web 控制台、shell、java)?这是本次训练中的第一次,还是第二次或第三次?
您可以尝试重写您的 match 子句,使
to
排在第一位吗?这应该不会有什么不同,但了解一下会很有趣。匹配到-[:TAGGED]->标签<-[:TAGGED]-类似
非常感谢。
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.