Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么我的Neo4J合并查询在创建新记录时速度慢?_Neo4j_Cypher - Fatal编程技术网

为什么我的Neo4J合并查询在创建新记录时速度慢?

为什么我的Neo4J合并查询在创建新记录时速度慢?,neo4j,cypher,Neo4j,Cypher,我正在使用数据库版本为3.5.6的Neo4J桌面 当我在空数据库和CSV中的775000条记录上运行下面的查询时,大约需要90秒。如果我再运行一次,大约需要25秒。这是典型的吗?我期望Neo4J能有很快的表现。我确实有索引和约束,所以查询计划以NodeUniqueIndexSeek开始。有没有更好的方法来编写查询 using periodic commit load csv with headers from file:///C:/Users/username/Documents/graphe

我正在使用数据库版本为3.5.6的Neo4J桌面

当我在空数据库和CSV中的775000条记录上运行下面的查询时,大约需要90秒。如果我再运行一次,大约需要25秒。这是典型的吗?我期望Neo4J能有很快的表现。我确实有索引和约束,所以查询计划以NodeUniqueIndexSeek开始。有没有更好的方法来编写查询

using periodic commit
load csv  with headers from file:///C:/Users/username/Documents/graphene_dev/csv/bugs.csv' as line
merge (n:Bug {id: line.id})
    set n.id = line.id,
    n.title = line.title,
    n.status = line.status,
    n.status_reason = line.status_reason,
    n.submitted_by = line.submitted_by, 
    n.owner = line.owner,
    n.submitted_date = line.submitted_date;
这些是我更改的Java设置


即使节点已经存在,您的查询仍将设置它们的属性。这可能不是你想要的(当然也需要一些时间)

如果只希望查询设置由
MERGE
新创建的节点的属性,则应使用子句,如中所示:

using periodic commit
load csv with headers from file:///C:/Users/username/Documents/graphene_dev/csv/bugs.csv' as line
merge (n:Bug {id: line.id})
on create set
    n.title = line.title,
    n.status = line.status,
    n.status_reason = line.status_reason,
    n.submitted_by = line.submitted_by, 
    n.owner = line.owner,
    n.submitted_date = line.submitted_date;
此查询在第二次运行时应该快得多,特别是因为您在
:Bug(id)
上有索引


顺便说一下,我的查询的
set
子句省略了冗余的
n.id=line.id
赋值,因为
merge
子句已经保证
n.id
等于
line.id

。这太棒了。我还可以使用“匹配集”设置任何可能更改的字段