Database Reference
In-Depth Information
As you can see, the increase in data by a thousand times didn't significantly affect Neo4j's
performance. The traversal does get slower as you increase the depth, but the main reason
forthatistheincreasednumberofresultsthatarereturned.Theperformanceslowslinearly
withtheincreaseoftheresultsize,andit'spredictableevenwithalargerdatasetanddepth
level. In addition, this is at least a hundred times better than the corresponding MySQL
performance.
The main reason for Neo4j's predictability is the localized nature of the graph traversal; ir-
respectiveofhowmanynodesandrelationshipsareinthegraph,thetraversalwillonlyvis-
it ones that are connected to the starting node, according to the traversal rules. Remember,
relational join operationscomputetheCartesian productbeforediscardingirrelevant res-
ults, affecting performance exponentially with the growth of the data set. Neo4j, however,
only visits nodes that are relevant to the traversal, so it's able to maintain predictable per-
formance regardless of the total data set size. The more nodes the traversal has to visit, the
slower the traversal, as you've seen while increasing the traversal depth. But this increase
is linear and is still independent of the total graph size.
What is the secret of Neo4j's speed?
No, Neo4j developers haven't invented a superfast algorithm for the military. Nor is
Neo4j's speed a product of the fantastic speed of the technologies it relies on (it's imple-
mented in Java after all!).
Thesecretisinthedatastructure—thelocalized natureofgraphsmakesitveryfastforthis
type of traversal. Imagine yourself cheering on your team at a small local football stadium.
If someone asks you how many people are sitting 15 feet around you, you'll get up and
countthem—you'llcountpeoplearoundyouasfastasyoucancount.Nowimagineyou're
attending the game at the national stadium, with a lot more spectators, and you want to an-
swer the same question—how many people are there within 15 feet of you. Given that the
density of people in both stadiums is the same, you'll have approximately the same num-
ber of people to count, taking a very similar time. We can say that regardless of how many
people can fit into the stadium, you'll be able to count the people around you at a predict-
able speed; you're only interested in the people sitting 15 feet around you, so you won't be
worried about packed seats on the other end of the stadium, for example.
Search WWH ::




Custom Search