【问题标题】:Very slow insertion performance in OrientDB via Java API通过 Java API 在 OrientDB 中的插入性能非常慢
【发布时间】:2015-03-27 11:50:36
【问题描述】:

我正在评估用图形数据库替换关系数据库。我正在尝试将数据从原始数据库复制到 OrientDB(2.0 版)。 我通过OServer server = OServerMain.create(); 创建了一个嵌入式服务器,将false 传递给storage.useWAL。 然后我创建一个非事务图:

OrientBaseGraph graph = new OrientGraphNoTx("plocal:"+db);
graph.declareIntent(new OIntentMassiveInsert());
graph.getRawGraph().declareIntent(new OIntentMassiveInsert());
graph.getRawGraph().setValidationEnabled(false);

我为所有表创建顶点类型。我首先为每个顶点创建所有顶点及其属性:

OrientVertex node = graph.addVertex("class:"+lbl, properties);

然后我在这些顶点之间创建边。这些边中的一些(但不是全部)具有属性。

if (props!=null){
    nfrom.addEdge(linkName, nto,null,null,props);
} else {
    nfrom.addEdge(linkName, nto);
}

我尝试过使用和不使用边缘类,没有发现任何性能改进。 总而言之,我有 328822 个顶点和 831293 个边。总运行时间最多25分钟左右!!大部分时间(至少 20 分钟)用于插入边,而不是顶点。

在同一台机器上,从同一个关系数据库中读取相同的数据并用 BerkeleyDB 后端将其写入 Titan,我在 2 分钟内传输数据!

是什么让 OrientDB 比竞争对手慢了大约 10 倍?我做错了什么?

谢谢!

【问题讨论】:

  • 你也可以分享泰坦代码(骨架)吗?然后我会有一个有效的参考。我对 OrientDB(作为嵌入式数据库)的体验就其性能而言非常好。

标签: graph-databases orientdb


【解决方案1】:

当您有许多边时,最好使用事务图并提交每个 X 项。此外禁用 TX 的日志。示例:

OrientBaseGraph graph = new OrientGraph("plocal:"+db);
try{
  graph.getRawGraph().getTransaction().setUsingLog(false);

  int saved = 0;
  while(){ // this is your loop
    ....

    saved++;

    if( saved % 5000 == 0 ){
      graph.commit();
      graph.getRawGraph().getTransaction().setUsingLog(false);
    }
  }
  graph.commit();

} finally {
  graph.close();
}

【讨论】:

  • Mmhh,文档的 Graph API 上的性能调整页面说“尽可能避免事务”。我确实在我的测试中使用了这样一个事务系统,没有setUsingLog(false),并且批量较小。如果我按照你的建议使用 5000,我会得到 com.orientechnologies.orient.core.exception.ODatabaseException: Error on saving record ... Caused by: java.lang.StackOverflowError at com.orientechnologies.orient.core.tx.OTransactionOptimistic.addRecord(OTransactionOptimistic.java:287)
  • 用 -Xss4M 再试一次,这次没有 StackOverflowError,27 分钟。所以没有收获。 OrientDB 仍然比 Titan 慢 10 倍。
  • 能分享一下代码吗?你有什么样的输入文件?
  • 没有输入文件,我们从关系数据库中读取数据。所以不,我不能真正分享代码,但同事们已经获得了类似的性能,只是随机插入带有大量边的顶点。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-24
  • 1970-01-01
  • 1970-01-01
  • 2020-04-02
  • 2014-06-05
  • 2010-10-24
相关资源
最近更新 更多