4

I am working on a project where tons of graph operations are performed in near real-time. We are currently using Hibernate, MySQL and EhCache but considering moving all the graph-related persistence to a graph database like Neo4j or Titan.

Can graph databases perform better than Hibernate+relational? I just want to make sure we are not going to replace six of one with half a dozen of the other.

izilotti
  • 4,757
  • 1
  • 48
  • 55

4 Answers4

9

The deeper the object graph, the more the performance advantage swings to object/graph databases.

Relational database performance drops off markedly with more than seven JOINs.

Geometric systems such as CAD/CAM, with deep object graphs for bills of materials, outperform their relational counterparts.

Relational databases have one huge advantage: relational algebra and a clear separation between the data and the "how" of accessing and manipulating it. But they are not perfect for every problem.

duffymo
  • 305,152
  • 44
  • 369
  • 561
4

The advantage you have when moving to neo4j (or some graph db) is that the query time remains constant (well almost) and hence predictable irrespective of the increase in data volume. It always better to do a proof-of-concept based on your data domain as generalized answers are generally not applicable for nosql dbs.

Taken from here. enter image description here

Aravind Yarram
  • 78,777
  • 46
  • 231
  • 327
1

Both graph and relational databases rely on caches to improve query performance. However, an edge traversal in a graph database is usually a constant time operation, and the edge is typically cached if the vertex is cached. With an RDBMS, a foreign key traversal requires a B-Tree index lookup on the target table which takes O(log n) time. When the index doesn't fit in the cache, the database would have to perform disk-seek operations which are slow.

Check out Bitsy. If your graph fits in memory, it is very fast for queries and updates. Or you can go with another Blueprints implementation, like Neo4J and Titan, which can handle larger datasets.

0

If you're using Hibernate then you're persisting domain objects which by their nature ARE object graphs.

Databases are tabular structures and do OK with this relationship but break down fast. In addition, Hibernate has a nasty habit of pulling in the entire database with joins.

Given that Neo4j was designed with object relations as it's core function and you're doing domain persistence, this nature design fit is sure to be better.

Also, Neo4j does its queries using Lucene (a stupid fast search index) and can jump straight to your node for traversal.

Bottom line: Neo4j was design for mind blowing scale and exactly the idea of graph-related data. You're not going wrong for scaling but you will find the tools/libraries aren't as mature for the job as they are for a classic DB connection

Christian Bongiorno
  • 5,150
  • 3
  • 38
  • 76