我的Neo4j查询的可扩展性存在问题。 我试图用这些查询填充数据库:
CREATE (Visitor1: Visitor {MAC:'00:0a:95:9d:68:16'})
CREATE (Visitor2: Visitor {MAC:'a7:e1:29:0f:7b:42'})
…
CREATE (CheckPoint1: CheckPoint {CheckPointId: 1})
CREATE (CheckPoint2: CheckPoint {CheckPointId: 2})
…
CREATE (Visitor1)-[:MAKES]->(Visit1: Visit {EnterTime: 1491061320000})-[:TO]->(CheckPoint1)
CREATE (Visitor1)-[:MAKES]->(Visit2: Visit {EnterTime: 1491061860000})-[:TO]->(CheckPoint46)
…
这些查询是由我编写的脚本生成的。已成功为10位访问者和100位访问者创建数据库。但是当我尝试创建1000个访问者(50个检查点和大约6000次访问)时,数据库会抛出异常:
There is not enough memory to perform the current task. Please try increasing ‘dbms.memory.heap.max_size’ in neo4j configuration.
我认为问题出在我的查询上。任何想法如何改进它?
我将非常感谢你的帮助!
答案 0 :(得分:1)
您要做的是在查询中使用参数。不知道如何加载数据,但一般的例子看起来像这样。
MERGE (Visitor1: Visitor {MAC:params.mac})
MERGE (CheckPoint1: CheckPoint {CheckPointId: params.checkpoint})
CREATE (Visitor1)-[:MAKES]->(Visit2: Visit {EnterTime: params.enterTime})-[:TO]->(CheckPoint1)
希望这会有所帮助