neo4j中时间过滤器的性能,其中 [英] performance of time filters in neo4j where

查看:115
本文介绍了neo4j中时间过滤器的性能,其中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,这是一个neo4j图形数据库设计问题.在date属性上有一个where过滤器性能相对较高,还是应该开始创建节点和关系来帮助过滤该过滤器.

So this is a neo4j graph database design question. Is having a where filter on a date property relatively performant or should I start to create nodes and relationships to help filter that.

例如,使用neo4j电影图示例.

For instance, using the neo4j movie graph example.

MATCH (nineties:Movie) WHERE nineties.released > 1990 
AND nineties.released < 2000 RETURN nineties.title

如果有数百万部电影,此查询将执行类似于对所有电影进行表扫描然后过滤的操作-是否可以在Movie.released上创建索引来避免这种情况?

If there were millions of movies, would this query be doing what would be akin to a table scan of all movies and then filtering - would creating an index on Movie.released be the way to avoid that?

还是最好每十年有一个节点,比如说六十,七十,八十等,并将每个电影与该节点相关联,以提高查询效率?

Or is it better to have a node for each decade, say sixties, seventies, eighties, etc... and relating each movie to that node be more efficient query-wise?

如果它是一个更具动态性的时间查询,例如最近7天上映的电影,该怎么办?仅在发布时创建索引并添加where子句就足够好了吗?或者该方法有陷阱吗?

What if it was a more dynamic time query, like movies released in the last 7 days - would just creating the index on released and adding the where clause be good enough or are there pitfalls to that approach?

推荐答案

使用<查找节点属性.和>不是那种表演者",我的意思是遍历关系会更快.

Looking up on node properties with < and > is not that "performant", I mean that it is quicker to traverse relationships.

实际上,在Neo4j中管理时间是一种常见的用例,您需要改变主意.

In fact, managing times in Neo4j is a common use case where you need to have a mind shift.

通常,我们使用时间树和事件,或者在您的用例中,电影会与时间树的1990年节点关联RELEASED_IN.

Generally we use time trees and events or in your use cases movies would then have a relationship RELEASED_IN connected to the 1990 year node of the Timetree.

您可能想要看看GraphAware TimeTree Neo4j插件,该插件将在后台进行处理:

You may want to look at the GraphAware TimeTree Neo4j plugin that will handle this under the hood :

https://github.com/graphaware/neo4j-timetree

这篇关于neo4j中时间过滤器的性能,其中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆