neo4j与mysql相比的性能(怎么能改进?)

这是一个后续行动, 无法在行动手册中重现/validationgraphics数据库和neo4j中的性能声明 。 我已经更新了设置和testing,不想太多改变原来的问题。

整个故事(包括脚本等)在https://baach.de/Members/jhb/neo4j-performance-compared-to-mysql

简短的版本:当试图validation在“图数据库”书中的性能声明时,我得出以下结果(查询包含n个人的随机数据集,每个数据集有50个朋友):

My results for 100k people depth neo4j mysql python 1 0.010 0.000 0.000 2 0.018 0.001 0.000 3 0.538 0.072 0.009 4 22.544 3.600 0.330 5 1269.942 180.143 0.758 

“*”:仅限单次运行

 My results for 1 million people depth neo4j mysql python 1 0.010 0.000 0.000 2 0.018 0.002 0.000 3 0.689 0.082 0.012 4 30.057 5.598 1.079 5 1441.397* 300.000 9.791 

“*”:仅限单次运行

在64位ubuntu上使用1.9.2我已经设置了neo4j.properties这些值:

 neostore.nodestore.db.mapped_memory=250M neostore.relationshipstore.db.mapped_memory=2048M 

和neo4j-wrapper.conf:

 wrapper.java.initmemory=1024 wrapper.java.maxmemory=8192 

我对neo4j的查询看起来像这样(使用REST api):

 start person=node:node_auto_index(noscenda_name="person123") match (person)-[:friend]->()-[:friend]->(friend) return count(distinct friend); 

显然,Node_auto_index就位

有什么我可以做,以加快neo4j(要更快,然后mysql)?

而且在Stackoverflow中还有另外一个基准问题。

对不起,你不能重现结果。 然而,在具有2GB堆,GCRcaching但没有caching温度boost的MacBook Air(1.8GHz i7,4GB RAM)上,并且没有其他调整,具有相似大小的数据集(100万个用户,每个50个朋友) ,我使用1.9.2的遍历框架重复获得大约900毫秒:

 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速度较慢,但​​速度不如您build议的慢:约3秒:

 START person=node:user(name={name}) MATCH (person)-[:FRIEND]->()-[:FRIEND]->()-[:FRIEND]->()-[:FRIEND]->(friend) RETURN count(friend) 

亲切的问候

伊恩

是的,我相信REST API比常规绑定慢得多,其中存在性能问题。