Neo4j持久查询要拆分/执行成较小的块? [英] Neo4j long lasting query to be split/executed in smaller chunks?
问题描述
我的import.csv
创建了许多节点,并且合并创建了一个巨大的笛卡尔积,并在transaction timeout
中运行,因为数据增长了很多.我目前将事务超时设置为1秒,因为所有其他查询都非常快,并且完成时间不应超过一秒.
My import.csv
creates many nodes and merging creates a huge cartesian product and runs in a transaction timeout
since the data has grown so much. I've currently set the transaction timeout to 1 second because every other query is very quick and is not supposed to take any longer than one second to finish.
是否有一种方法可以将较小的块拆分或执行此特定查询,以防止超时?
Is there a way to split or execute this specific query in smaller chunks to prevent a timeout?
不能选择在neo4j.conf
中添加或禁用transaction timeout
,因为neo4j服务需要重新启动配置中的所有更改.
Upping or disabling the transaction timeout
in the neo4j.conf
is not an option because the neo4j service needs a restart for every change made in the config.
查询击中了我的导入脚本的超时时间:
The query hitting the timeout from my import script:
MATCH (l:NameLabel)
MATCH (m:Movie {id: l.id,somevalue: l.somevalue})
MERGE (m)-[:LABEL {path: l.path}]->(l);
节点数:1000电影,2500名称标签
Nodecounts: 1000 Movie, 2500 Namelabel
推荐答案
您可以尝试安装 APOC程序,并使用过程 apoc.periodic.commit .
You can try installing APOC Procedures and using the procedure apoc.periodic.commit.
call apoc.periodic.commit("
MATCH (l:Namelabel)
WHERE NOT (l)-[:LABEL]->(:Movie)
WITH l LIMIT {limit}
MATCH (m:Movie {id: l.id,somevalue: l.somevalue})
MERGE (m)-[:LABEL {path: l.path}]->(l)
RETURN count(*)
",{limit:1000})
下面的查询将在单独的事务中重复执行,直到返回0.
The below query will be executed repeatedly in separate transactions until it returns 0.
您可以更改{limit : 1000}
的值.
注意:请记住要根据所使用的Neo4j的版本安装APOC程序.看看版本兼容性列表..
这篇关于Neo4j持久查询要拆分/执行成较小的块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!