批量删除组OrientDB/Java [英] Mass / Group Delete OrientDB / Java

查看:122
本文介绍了批量删除组OrientDB/Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试原型化orientdb大量删除顶点的性能结果.我需要创建原型以尝试删除10000到上百万.

I am trying to prototype performance results of orientdb mass delete of vertexes. I need to prototype trying to delete more than 10000 upto million.

首先,在按照此步骤创建顶点和边时,我使用轻量级的edges属性为false

Firstly, I am using the light weight edges property to be false while creating my vertices and edges following this Issue with creating edge in OrientDb with Blueprints / Tinkerpop

当我尝试删除时(请参阅下面的代码)

When I try deleting (Please see below the code)

private static OrientGraph graph = new OrientGraph(
        "remote:localhost/WorkDBMassDelete2", "admin", "admin");
private static void removeCompleatedWork() {

    try {
        long startTime = System.currentTimeMillis();
        List params = new ArrayList();
        String deleteQuery = "delete vertex Work where out('status') contains (work-state = 'Not Started')";
        int no = graph.getRawGraph().command(new OCommandSQL(deleteQuery))
                .execute(params);
        // graph.commit();
        long endTime = System.currentTimeMillis();
        System.out.println("No of activities removed : " + no
                + " and time taken is : " + (endTime - startTime));
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        graph.shutdown();
    }
}

如果我尝试在100的500个活动中删除大约需要500毫秒,结果将是不错的.但是,当我尝试删除2500/5000活动时,对于2500次删除而言,否定值很高,大约需要6000次.

The Results are good if I tring to delete in 100's 500 activities take ~500 ms. But when i trying to delete 2500/5000 activities the no's are high for 2500 deletions it takes ~6000.

A)我也尝试创建索引.在属性工作状态上创建索引或在边缘状态上创建索引的最佳实践是什么?我在创建顶点和边时都尝试过.但是两者都不能很好地改善性能.

A) I also tried creating index. What is the best practise to create a index on the attribute work-state or to create index on the edge status? I tried both while creating the vertex and edge. But both are not improving the performance a lot.

((OrientBaseGraph) graph).createKeyIndex("Status", Edge.class);
//or on the vertex
((OrientBaseGraph) graph).createKeyIndex("work-state", Vertex.class);

使用上述查询删除质量/组数据的最佳实践是什么?任何帮助,我们将不胜感激.

What is the best practice to delete mass/group data using the query like mentioned above? Any help is greatly appreciated.

更新:

我从当我尝试使用Studio/程序中的子查询删除时,出现以下错误:com.orientechnologies.orient.core.sql.OCommandSQLParsingException:解析位置#0的命令时出错:找不到类'FROM.我已经像这样修改了我的查询:

When I try deleting using the subquery from the studio / program I get the following error:com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error on parsing command at position #0: Class 'FROM was not found . I had modified my query like this:

delete vertex from (select in('status') from State where work-state = 'Complete')

当我通过程序运行它时,我将maven依赖项更新为1.7-SNAPSHOT库.我的旧查询仍然产生相同的数字,即使在Studio中,子查询删除也给出了错误.如果我有任何遗漏,请告诉我.谢谢!!

Also while I ran it through program I updated my maven dependencies to 1.7-SNAPSHOT libraries. My old query was still producing the same numbers and the subquery deletion was giving errors even in studio. Please let me know if I am missing anything. Thanks !!

推荐答案

首先,请使用1.7-SNAPSHOT尝试相同的代码.它应该更快.

First, please try the same exact code with 1.7-SNAPSHOT. It should be faster.

然后在1.7-SNAPSHOT中,我们仅添加了从子查询中删除顶点的功能.这是因为为什么当您可以从状态顶点未开始"中删除所有传入的顶点时浏览所有作品?

Then in 1.7-SNAPSHOT we just added the ability to delete vertices from a sub-query. This is because why browsing all the Work when you could delete all the incoming vertex from the Status vertex "Not Started"?

因此,如果您的版本为1.7-SNAPSHOT,则可以从以下位置更改此查询:

So if you've 1.7-SNAPSHOT change this query from:

delete vertex Work where out('status') contains (work-state = 'Not Started')

to(假设状态顶点称为状态"):

to (assuming the status vertex is called "State"):

delete vertex from (select in('status') from State where work-state = 'Not Started')

这篇关于批量删除组OrientDB/Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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