与MySQL相比,neo4j的性能(如何改进?) [英] neo4j performance compared to mysql (how can it be improved?)
问题描述
这是对无法在图形数据库和动作书中的neo4j中再现/验证性能要求的后续行动.我已经更新了设置和测试,并且不想过多更改原始问题.
This is a follow up to can't reproduce/verify the performance claims in graph databases and neo4j in action books. I have updated the setup and tests, and don't want to change the original question too much.
整个故事(包括脚本等)位于 https://baach.de/Members/jhb/neo4j-performance-compared-to-mysql
The whole story (including scripts etc) is on https://baach.de/Members/jhb/neo4j-performance-compared-to-mysql
简短版本:在尝试验证图形数据库"这本书中的性能要求时,我得到了以下结果(查询包含n个人,每个有50个朋友的随机数据集):
Short version: while trying to verify the performance claims made in the 'Graph Database' book I came to the following results (querying a random dataset containing n people, with 50 friends each):
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:
Using 1.9.2 on a 64bit ubuntu I have setup neo4j.properties with these values:
neostore.nodestore.db.mapped_memory=250M
neostore.relationshipstore.db.mapped_memory=2048M
和neo4j-wrapper.conf带有:
and neo4j-wrapper.conf with:
wrapper.java.initmemory=1024
wrapper.java.maxmemory=8192
我对neo4j的查询如下所示(使用REST API):
My query to neo4j looks like this (using the REST api):
start person=node:node_auto_index(noscenda_name="person123") match (person)-[:friend]->()-[:friend]->(friend) return count(distinct friend);
显然,Node_auto_index到位了
Node_auto_index is in place, obviously
我可以做些什么来加快neo4j的速度(快于mysql)吗?
And also there is another benchmark in Stackoverflow with same problem.
推荐答案
对不起,您无法复制结果.但是,在具有2 GB堆的MacBook Air(1.8 GHz i7,4 GB RAM)上,具有GCR缓存,但没有预热缓存,也没有其他调整,并且数据集的大小相同(100万用户,每人50个朋友) ,我在1.9.2上使用遍历框架反复获得了大约900毫秒的时间:
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速度较慢,但远没有您建议的那么慢:大约3秒:
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)
亲切的问候
ian
这篇关于与MySQL相比,neo4j的性能(如何改进?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!