在我的测试中,NE4J似乎比MySQL慢。如何使它更快? [英] In my tests, NE4J seems so slow compared to MySQL. How can I make it faster?

查看:140
本文介绍了在我的测试中,NE4J似乎比MySQL慢。如何使它更快?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是NEO4J的新手,我想看看它有多快。我开始测试它,我创建了一个表在MySQL和NEO4J,这些属性(字段):

  id random_number time_stamp 

我写了一个程序来生成大量数据并插入了大约1.5亿行(Neo4J中的节点) 。我可以说写入速度几乎相同。



所以,我测试了一个选择查询在两个数据库。 我想要获得一个带有random_id为255454的行(节点)(我们知道从这个随机ID有超过30行)



NEO4J:

 匹配(t:testLabel {random_id:255454})RETURN t LIMIT 50; 

MySQL:

  SELECT * 
FROM test
WHERE random_id = 255454 LIMIT 50

NEO4J耗时约47秒,MySQL花费约25秒来返回结果。



NEO4J磁盘大小变为〜35GB,MySQL大小在磁盘上变为〜5.2 GB



这两个数据库在表或属性上没有索引。



硬件: CPU: Corei7-4770 | RAM: 12GB | SSD硬盘






这是一个简单的测试,我的意思是两个数据库都很简单,想,NEO4J比MySQL快。
我真的很喜欢NEO4J我想找到一个解决方案并再次使用。



根据我的简单测试,NEO4J不适合大型和可扩展项目。我想知道也许有一些方法,使它惊人的更快!
性能测试是如此简单,所有数据库都必须有它,不管数据建模。



在磁盘上的大小怎么样?



+我发现另一个比较疑问 byJörgBaach,您可能会喜欢。

解决方案

比较关系数据库和图形数据库是一项巨大的任务。



我认为一个更有用的测试将是检查跨多个表的查询的性能与几个连接和fk。对比neo4j,你会发现,可能比mysql更好的性能。



这样做:使用你的测试模型设置4-5个可能的用例。一些dba会做的事情,一些用户会做的事情等。确定有多少人会做这个,确定他们将多久做一次。



选择简单任务和复杂任务。将MySQL性能与Neo4J进行比较。你会发现一个数据库在不同情况下胜过另一个数据库。



尝试权衡你的优先级。对于在具有某个属性的50个节点上匹配时具有很好的性能,它有多重要。对你来说重要的是,用户(几十 - 几百万)将有快速,安全的方法来创建广泛复杂的关系网络。一旦你确定什么是重要的,请参考性能测试,并确定哪个数据库更适合你的需要。



如果你要执行基本的查询,你应该使用关系数据库模型像sql。 Neo4j非常适合复杂的模式和查询,不仅从性能角度,而且从可读性的角度。



Neo4j以非常不同的方式存储数据,区别。



Cypher以图形模式为中心,这些模式是您的使用案例的核心,并以可视化的形式表示它们的查询语法。 p>

本文是真正有见地,展示了从关系数据库到图形数据库的过渡。


I am new to NEO4J and I wanted to see how fast it is. I started to test it and I created a table in both MySQL and NEO4J, with these properties (fields):

id    random_number    time_stamp

And I wrote a program to generate mass data and inserted about 150 million rows (and Nodes in Neo4J). I can say the write speed was almost same.

So, I tested a select query in both databases. "I wanted to get one of the rows(nodes) with the random_id of 255454" (we know from this random id there are more than 30 rows)

NEO4J:

match (t:testLabel {random_id: 255454}) RETURN t LIMIT 50;

MySQL:

SELECT * 
FROM  test 
WHERE  random_id=255454 LIMIT 50

NEO4J took ~47 seconds and MySQL took about ~25 seconds to return results.

NEO4J size on disk became ~35GB and MySQL size on disk became ~5.2 GB

And both databases did not have index on the table or properties.

Hardware: CPU: Corei7-4770 | RAM: 12GB | SSD Hard disk


This is a simple test, I mean both databases were so simple and had basic structures and before testing I thought, NEO4J is faster than MySQL. As I really like NEO4J I want to find a solution and use it again.

According to my simple test, NEO4J is not reasonable for big and scalable projects. I want to know maybe there are some ways that make it amazingly faster! The performance test was so simple and all databases have to have it as well regardless of data modeling.

And what about the size on disk?

+ I found another comparing question by Jörg Baach that you may like to see.

解决方案

Comparing relational databases and graph databases is a huge task.

I think a much more helpful test would be to check performance on queries across multiple tables with several joins and fk. Compare that to neo4j and you will find, possibly much better performance than mysql.

Do this: With your test model set up 4-5 possible use cases. A couple things that a dba will be doing, a couple things that users will be doing etc. Determine how many people are going to be doing this, determine how often they will be doing this.

Choose simple tasks, and complex tasks. Compare MySQL performance to Neo4J. You will find that one DB outperforms the other in different situation.

Try to weigh what your priorities are. How important is it to you to have great performance on matching 50 nodes with a certain property. How important is to you that users (dozens? milions?) will have fast, secure method of creating extensively complex networks of relationships? Once you determine what is important to you refer to the performance tests and determine which db is better for your needs.

If you are going to be performing basic queries you should probably use relational database model like sql. Neo4j is great for complex schemas and queries , not only from a performance perspective but from a readability standpoint.

Neo4j is storing data in a very different way, hence the disk storage difference.

Cypher is centered around the graph patterns that are core to your use-cases and represents them visually as part of its query syntax.

This article is really insightful, shows the transition from relational to graph databases.

这篇关于在我的测试中,NE4J似乎比MySQL慢。如何使它更快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆