4

Is it true that relational database, like MySql, performs better than a graph database, like Neo4j, when a query is about to search for specific data within a specific table and a specific column.

For instance, if the query is: "search for all events that took place in Paris".

Let's assume for simplicity that MySql would have an Event table with an index upon "City" to optimize this kind of query.

What about Neo4j? One might think that a graph database has to traverse all graphs to retrieve the concerned events... However it's possible to create some indexes with Neo4j as its documentation precises.

Why RDMBS would be faster than it for this kind of analysis/statistics request?

Mik378
  • 21,881
  • 15
  • 82
  • 180

1 Answers1

6

As you already mentioned: you would create indices for this purpose. The default index provider in Neo4j is lucene, which is very fast and allows fine grained indexing and querying possibilities.

Indices can be used for nodes or relationships and (normally) keep track which values have been set on certain properties on nodes or relationships.

You normally have to do the indexing in your application code unless you're using neo4j's auto indexing feature that automatically indexes all nodes and/or relationships with given properties.

So queries like "search for all events that took place in Paris" are absolutely no problem and are very performant when indices are used.

James
  • 11,654
  • 6
  • 52
  • 81
  • Thanks for this clear explanation :) In this post: http://stackoverflow.com/questions/13046442/comparision-of-relational-databases-and-graph-databases, it is said : "A relational database is much faster when operating on huge numbers of records"=> would be true unless some indexes are set up, if I figure out your thinking. Besides, I'm about to create a large project using a graph database (Neo4j) since a lot of relationships have to be occured. Does it make sense to associate to Neo4j some relational database (for other cases that I might ignore) or it is sufficient to itself. Thanks a lot! – Mik378 Jan 15 '13 at 14:46
  • I cannot say if you need a RDBMS besides Neo4j. But having two DBs makes life definitifely not easier - thinking e.g. about transaction management, high availability setup, backup, other operational tasks etc. – James Jan 15 '13 at 14:54