Is Neo4j faster than SQL?

neo4j, nosql, sql

Solution

Neo4j ist not generally faster than an SQL database. 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 stores it's data as nodes and relationships between these nodes. 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. So you will end up with a lot of queries.

Problem

I am a newbie to Neo4j, and can't quite understand why Neo4j must be faster than an efficient SQL query. Is it because of data structure or underlying query implementation? I really appreciate if someone can help me to get a crack on this.

Original source