neo4j performance compared to mysql (how can it be improved?)
I'm sorry you can't reproduce the results. However, on a MacBook Air (1.8 GHz i7, 4 GB RAM) with a 2 GB heap, GCR cache, but no warming of caches, and no other tuning, with a similarly sized dataset (1 million users, 50 friends per person), I repeatedly get approx 900 ms using the Traversal Framework on 1.9.2:
public class FriendOfAFriendDepth4{ private static final TraversalDescription traversalDescription = Traversal.description() .depthFirst() .uniqueness( Uniqueness.NODE_GLOBAL ) .relationships( withName( "FRIEND" ), Direction.OUTGOING ) .evaluator( new Evaluator() { @Override public Evaluation evaluate( Path path ) { if ( path.length() >= 4 ) { return Evaluation.INCLUDE_AND_PRUNE; } return Evaluation.EXCLUDE_AND_CONTINUE; } } ); private final Index<Node> userIndex; public FriendOfAFriendDepth4( GraphDatabaseService db ) { this.userIndex = db.index().forNodes( "user" ); } public Iterator<Path> getFriends( String name ) { return traversalDescription.traverse( userIndex.get( "name", name ).getSingle() ) .iterator(); } public int countFriends( String name ) { return count( traversalDescription.traverse( userIndex.get( "name", name ).getSingle() ) .nodes().iterator() ); }}
Cypher is slower, but nowhere near as slow as you suggest: approx 3 seconds:
START person=node:user(name={name})MATCH (person)-[:FRIEND]->()-[:FRIEND]->()-[:FRIEND]->()-[:FRIEND]->(friend)RETURN count(friend)
Kind regards
ian
Yes, I believe the REST API is significantly slower than the regular bindings and therein lies your performance problem.