Hi, all!
I create a neo4j db containing about 22,000,000 edges. Each edge contains a
long property "the_time". I found it is very slow to delete some relations.
I do it in the two transaction:
1. query relations on the property "the_time" using numeric range query
in one transaction.
2. delete relations by calling the Relation.delete() method in another
transaction.
I measure the time for each transaction, the first cost about 395 ms but
the second cost about 30578 ms, and the result set size is about 15000.
I use neo4j in embeded mode, and the JVM heap size is set to 20GB.
Here's my test code and thanks in advance!
long startQuery = System.currentTimeMillis();
List<Relationship> relationships = new ArrayList<>();
try (Transaction tx = graphDb.beginTx()) {
HashMap<String, Object> param = new HashMap<>();
RelationshipIndex index = graphDb.index().forRelationships("rel_the_time"
);
long start = ThreadLocalRandom.current().nextLong(TIME_MIN, TIME_MAX);
long end = start + TIME_RANGE;
param.put("start", start);
param.put("end", end);
IndexHits<Relationship> res = index.query(QueryContext.numericRange(
"the_time", start, end));
while (res.hasNext()) {
Relationship r = res.next();
relationships.add(r);
}
tx.success();
}
long queryCost = System.currentTimeMillis() - startQuery;
long deleteStart = System.currentTimeMillis();
try (Transaction tx = graphDb.beginTx()) {
RelationshipIndex index = graphDb.index().forRelationships("rel_the_time"
);
if (DELETE) {
for (Relationship r : relationships) {
r.delete();
index.remove(r);
}
}
tx.success();
}
System.out.println("Query cost: " + queryCost);
System.out.println("Delete cost: " + (System.currentTimeMillis() -
deleteStart));
--
You received this message because you are subscribed to the Google Groups
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.