【发布时间】:2018-02-15 02:35:33
【问题描述】:
我创建了一个以小时为单位的 Needham 时间树 (http://www.markhneedham.com/blog/2014/04/19/neo4j-cypher-creating-a-time-tree-down-to-the-day/)。 在每个小时节点上,我存储了纪元时间
CREATE (h:Hour {hour: hour, day:day, month: month, year:year, time: apoc.date.parse(year +"-"+month+"-"+day+" "+hour+":00", "s", "yyyy-MM-dd hh:mm")})
现在我想将该小时内发生的事件链接到小时节点。我通过以下查询做到了这一点:
//Create one example event node
create (e:Event {time: apoc.date.parse("2017-11-17 13:15", "s", "yyyy-mm-dd HH:mm")})
with e
match (h:Hour) where h.time <= e.time and (h.time+3600) > e.time
merge (e)-[:IN_HOUR]->(h)
我同时索引了事件时间和小时时间。
这对于小型事件组很有效,但是当我将事件扩展到数十万范围时,它会变得非常缓慢。 (每小时大约几百到 1000 个关系)
我怎样才能更快地做到这一点?
我都试过了
match (e:Event) ...`
和using load CSV 遍历每个事件,将其与现有事件节点匹配,然后创建与时间树的关系。
`
【问题讨论】: