Graph 如何在Neo4j中提高查询效率?
我需要使用函数apoc.export.cyphe.data()导出数据库的一部分。 下面是我用来调用函数的代码:Graph 如何在Neo4j中提高查询效率?,graph,neo4j,cypher,Graph,Neo4j,Cypher,我需要使用函数apoc.export.cyphe.data()导出数据库的一部分。 下面是我用来调用函数的代码: MATCH path = (p1:Author)-[r:CO_AUTHORSHIP]-(p2:Author) WITH collect(p1)+collect(p2) as export_nodes,collect(r) as export_rels CALL apoc.export.cypher.data(export_nodes,export_rels,'/tmp/expor
MATCH path = (p1:Author)-[r:CO_AUTHORSHIP]-(p2:Author) WITH collect(p1)+collect(p2) as
export_nodes,collect(r) as export_rels CALL
apoc.export.cypher.data(export_nodes,export_rels,'/tmp/export.cypher',{format:'cypher-
shell',cypherFormat: 'updateAll'}) YIELD file, source, format, nodes, relationships,
properties,timeRETURN nodes, relationships, time
问题是查询
匹配路径=(p1:作者)-(r:合作作者)-(p2:作者)
花了一个多小时
我有一个数据库,有467437个合作作者关系。数据库的每个节点代表一个作者。对于每个关系边缘,我存储关于两位作者撰写的文章(文章数量、类型、地点、标题和年份)的数据
有没有办法提高查询的效率?您的查询将每个
作者
放入导出节点
多次,每个合作作者关系
放入导出关系
多次。这应该更快,使用更少的内存:
MATCH path = (a:Author)-[r:CO_AUTHORSHIP]-()
WITH COLLECT(DISTINCT a) AS export_nodes, COLLECT(DISTINCT r) AS export_rels
CALL apoc.export.cypher.data(
export_nodes, export_rels, '/tmp/export.cypher',
{format:'cypher-shell', cypherFormat: 'updateAll'}) YIELD nodes, relationships, time
RETURN nodes, relationships, time