我仍然怀疑orientdb的性能。纯粹插入图形的最高性能是2000 edge / s,而更新和插入的最高性能是250 edge / s。
我的代码在这里,与@Nandna Chowdhury非常相似
仅限插入的代码:
def insertiongraphtest(graph: OrientGraphNoTx): Unit ={
println(new Date())
for(vcount <- 1 to 1000){
val vertex1 = graph.addVertex("class:CLASS1",
"prop1",vcount.asInstanceOf[java.lang.Integer],"prop2","22","prop3","3333" )
for(vc <- 1 to 1000){
val vertex2 = graph.addVertex("class:CLASS2",
"prop1",(vcount+vc/1000).asInstanceOf[java.lang.Integer],"prop2","22","prop3","3333" )
graph.addEdge(null,vertex1,vertex2,"v12v2")
}
graph.commit()
}
println(new Date())
}
插入和更新的代码:
def insertupdategraphtest(graph: OrientGraphNoTx): Unit ={
println(new Date())
val vertex1type = graph.createVertexType("CLASS1")
vertex1type.setOverSize(2)
val vertex2type = graph.createVertexType("CLASS2")
vertex2type.setOverSize(2)
graph.createKeyIndex("prop1",classOf[Vertex] ,
new Parameter("type", "UNIQUE"),
new Parameter("class", "CLASS1"))
graph.createKeyIndex("prop1",classOf[Vertex] ,
new Parameter("type", "UNIQUE"),
new Parameter("class", "CLASS2"))
var vertex1:OrientVertex = null
var vertex2:OrientVertex = null
for(icount <- 1 to 100){
for(vcount <- 1 to 10){
val v = graph.getVertices("CLASS1.prop1",vcount).asScala.
asInstanceOf[Iterable[OrientVertex]].iterator
if(v.hasNext){
while (v.hasNext){
vertex1 = v.next()
vertex1.detach()
vertex1.setProperty("prop2",new Date().toString)
vertex1.attach(graph)
vertex1.save()
}
}else{
vertex1 = graph.addVertex("class:CLASS1",
"prop1",vcount.asInstanceOf[java.lang.Integer],"prop2",new Date().toString,"prop3","3333" )
}
for(vc <- 1 to 1000){
val v2 = graph.getVertices("CLASS2.prop1",vc).asScala.
asInstanceOf[Iterable[OrientVertex]].iterator
if(v2.hasNext){
while (v2.hasNext){
vertex2 = v2.next()
vertex2.detach()
vertex2.setProperty("prop2",new Date().toString)
vertex2.attach(graph)
vertex2.save()
}
}else{
vertex2 = graph.addVertex("class:CLASS2",
"prop1",vc.asInstanceOf[java.lang.Integer],"prop2",new Date().toString,"prop3","3333" )
}
val edgeit = vertex1.getEdges(vertex2,Direction.OUT,"v12v2").asScala.iterator
if(edgeit.hasNext){
while (edgeit.hasNext){
edgeit.next()
}
}else{
graph.addEdge(null,vertex1,vertex2,"v12v2")
}
}
println(icount,vcount,new Date())
}
}
}
在我的代码中,我几乎都遵循所有调优技巧:
1.graph.declareIntent(new OIntentMassiveInsert())
2.indexing
3.vertex2type.setOverSize(2)
4.使用plocal
我的问题在这里:如果我需要检查数据库以决定是否插入或更新,那么提高性能的最佳方法是什么?
我从笔记本电脑上得到了结果。
有人对orientdb有适用的提示吗?
谢谢!