简体   繁体   English

Neo4j 比 SQL 快吗?

[英]Is Neo4j faster than SQL?

I am a newbie to Neo4j, and can't quite understand why Neo4j must be faster than an efficient SQL query.我是 Neo4j 的新手,不太明白为什么 Neo4j 必须比高效的 SQL 查询更快。 Is it because of data structure or underlying query implementation?是因为数据结构还是底层查询实现? I really appreciate if someone can help me to get a crack on this.如果有人可以帮助我解决这个问题,我真的很感激。

Neo4j ist not generally faster than an SQL database. Neo4j 通常并不比 SQL 数据库快。 It is just in many cases faster for graph based problems.在许多情况下,它对于基于图形的问题更快。 For example if you'd like to find the shortest path between two entities Neo4j will most likely outperform MySQL etc. because of the way the data is structured and the algorithms you can use because of this structure.例如,如果您想找到两个实体之间的最短路径,则 Neo4j 很可能会胜过 MySQL 等,因为数据的结构方式以及您可以使用这种结构的算法。 Neo4j stores it's data as nodes and relationships between these nodes. Neo4j 将其数据存储为节点以及这些节点之间的关系。 They are directly connected.它们是直接相连的。 A simple shortest path algorithm is a breadth-first search.一种简单的最短路径算法是广度优先搜索。 You start at one node and expand it's connected nodes, then for each of it's children you do the same, until you find the end node.您从一个节点开始并展开它的连接节点,然后对它的每个子节点执行相同的操作,直到找到结束节点。 This way you will touch only a small amount of data.这样您将只接触少量数据。 In an SQL query you can't do this easily, so you have to build something in your code, that traverses the result sets and generates new queries for each result and so on.在 SQL 查询中,您无法轻松做到这一点,因此您必须在代码中构建一些东西,遍历结果集并为每个结果生成新的查询等等。 So you will end up with a lot of queries.所以你最终会遇到很多查询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM