neo4j中时间过滤器的性能

时间:2021-09-16 18:02:42

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图数据库设计问题。在日期属性上具有相对高效的where过滤器,或者我应该开始创建节点和关系以帮助过滤它。

For instance, using the neo4j movie graph example.

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

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

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?

如果有数百万部电影,这个查询会做什么类似于所有电影的表扫描,然后过滤 - 会在Movie.released上创建一个索引,以避免这种情况吗?

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?

或者更好的是每个十年都有一个节点,比如六十年代,七十年代,八十年代等......并且将每个电影与该节点相关联的查询更有效?

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?

如果它是一个更动态的时间查询,比如过去7天发布的电影,那么只会在发布时创建索引并添加where子句足够好或者是否存在陷阱?

1 个解决方案

#1


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

使用 <和> 查找节点属性不是“高性能”,我的意思是遍历关系更快。

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

实际上,在Neo4j中管理时间是一个常见的用例,您需要进行思维转换。

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.

通常我们使用时间树和事件,或者在您的用例中,电影将具有连接到Timetree的1990年节点的RELEASED_IN关系。

neo4j中时间过滤器的性能

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

你可能想看看GraphAware TimeTree Neo4j插件,它将在幕后处理这个问题:

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

#1


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

使用 <和> 查找节点属性不是“高性能”,我的意思是遍历关系更快。

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

实际上,在Neo4j中管理时间是一个常见的用例,您需要进行思维转换。

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.

通常我们使用时间树和事件,或者在您的用例中,电影将具有连接到Timetree的1990年节点的RELEASED_IN关系。

neo4j中时间过滤器的性能

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

你可能想看看GraphAware TimeTree Neo4j插件,它将在幕后处理这个问题:

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