用Python在Neo4j中执行批量添加/插入的最快方法? [英] Fastest way to perform bulk add/insert in Neo4j with Python?

查看:109
本文介绍了用Python在Neo4j中执行批量添加/插入的最快方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当通过py2neo for Python使用REST API时,我发现Neo4j的添加节点和关系/弧/边的速度很慢.我了解这是由于每个REST API调用都是作为一个独立的事务执行的.

I am finding Neo4j slow to add nodes and relationships/arcs/edges when using the REST API via py2neo for Python. I understand that this is due to each REST API call executing as a single self-contained transaction.

具体来说,添加几百对具有它们之间关系的节点需要花费几秒钟的时间才能在本地主机上运行.

Specifically, adding a few hundred pairs of nodes with relationships between them takes a number of seconds, running on localhost.

在使用Python的同时显着提高性能的最佳方法是什么?

What is the best approach to significantly improve performance whilst staying with Python?

使用bulbflow和Gremlin是否可以构建批量插入交易?

Would using bulbflow and Gremlin be a way of constructing a bulk insert transaction?

谢谢!

推荐答案

有几种方法可以使用 py2neo 进行批量创建. a>,每个都只对服务器进行一次呼叫.

There are several ways to do a bulk create with py2neo, each making only a single call to the server.

  1. 使用create方法在单个批处理中构建许多节点和关系.
  2. 使用密码CREATE语句.
  3. 使用新的WriteBatch类(本周刚刚发布)来手动创建一批节点和关系(这实际上是1的手动版本).
  1. Use the create method to build a number of nodes and relationships in a single batch.
  2. Use a cypher CREATE statement.
  3. Use the new WriteBatch class (just released this week) to manually make a batch of nodes and relationships (this is really just a manual version of 1).

如果您有一些代码,我很乐于看一下并就性能调整提出建议.您还可以从中获得很多测试灵感.

If you have some code, I'm happy to look at it and make suggestions on performance tweaks. There are also quite a few tests you may be able to get inspiration from.

干杯, 尼日尔

这篇关于用Python在Neo4j中执行批量添加/插入的最快方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆