Insert query is very slow


#1

hi
insert query in java is very slow .
for example
"insert $x isa person " -------> 700 ms
"insert $x isa person has name “emad” " -------->2-3 s
"insert $x isa perons has name “emad” has firstsname “emad” has lastname “emad”" 3-5 s
is that ok? it is very slow not it? is there a problem ? or is it the normal speed for insert in grakn?
please help me


#2

That is slower than we experience here in the office. Can you give me an idea of the hardware you are using?

Sheldon


#3

i am using hp omen series and it is very powerful. intel core i7 CPU , 16 gigabyte RAM .
here is my java code :

GraknSession graph1 = Grakn.session(“localhost:4567”, “new”);
GraknGraph innerGraph = graph1.open(GraknTxType.WRITE);
QueryBuilder qb1 = innerGraph.graql();
long x = System.currentTimeMillis();
qb1.parse(“insert $x isa person has name “person3” ;”).execute();
innerGraph.commit();
long y = System.currentTimeMillis();
System.out.println(y-x);

the output in terminal :

2332


#4

Sorry it took a little while to get round to answering this one. I ran this modified test:

    public void slowQuery() {
        try (GraknSession session = Grakn.session("localhost:4567", "new")) {
            long x = System.currentTimeMillis();
            try (GraknGraph graph = session.open(GraknTxType.WRITE)) {
                ResourceType<String> name = graph.putResourceType("name", ResourceType.DataType.STRING);
                graph.putEntityType("person").resource(name);
                graph.commit();
            }
            long y = System.currentTimeMillis();
            System.out.println(y - x);
            x = System.currentTimeMillis();
            for (int i=0;i<100;i++) {
                try (GraknGraph graph = session.open(GraknTxType.WRITE)) {
                    QueryBuilder qb1 = graph.graql();
                    qb1.parse("insert $x isa person has name \"person3\" ;").execute();
                    graph.commit();
                }
            }
            y = System.currentTimeMillis();
            System.out.println(((double) (y - x))/100);
        }
    }

And get these two times output: 16962, 28.28. You can see that there is some overhead when you open the graph for the first time within the session, but subsequent writes are much faster.

Sheldon