r/Neo4j • • Mar 24 '22

Downsides of Graph Databases

Hello everyone. I have been looking into Neo4j and the graph db paradigm for a while, and I have to say I think it has some very compelling features. It feels like graph databases are the most sensible way to represent data, since it is the closest to how we model data in OO programming. However, it seems like the graph paradigm is struggling to take off has the mainstream way to store data, and I have no clue why that is. I assume that a good portion of the people in this subreddit have used Neo4j for a real world application, and therefore can testify on what would be the drawbacks of going the graph way. Are there any?

25 Upvotes

19 comments sorted by

5

u/NihaoPanda Mar 25 '22

Some of the things I've run into working with Neo4j in production are

  1. Frameworks such as Laravel/RoR are built around relational databases and won't let you take full advantage of the benefits of Neo4J

  2. Hiring becomes harder since it's a pretty rare skill

  3. Hosted solutions for relational db's are much cheaper

Then there are technical quirks that will frustrate you, but they're not dealbreakers

4

u/GioAc96 Mar 25 '22

These are fair points, but I'm really more interested into drawbacks of the tech itself, rather than real life struggles of using it. All of the problems you mentioned will eventually vanish if graph DB technology proves to be superior. Think of how Typescript overtook the web dev world within a few years, or how Go, Rust and Python have been taking off lately. I understand that DBs are more resistant to change since there's a higher cost of migration compared to changing programming language, but if graph is the superior model I'd be surprised if it doesn't get widely adopted in the next 10/20 years. (btw I don't know that graph is superior, I am looking for reasons why it might not be, but I'm struggling to find convincing arguments on this matter)

2

u/Reasonable_Strike_82 Mar 30 '23

For graph DBs to take off, it isn't enough to just be superior in principle. They have to be superior in practice. And that is a high bar to clear, given the many decades and millions of dev-hours invested in RDBMs.

And, frankly, I don't see it. I've worked extensively with Neo4j on several projects over quite a few years, and I always found myself wondering if I'd have been better off just hacking something together on top of a SQL database. There are many use cases where a graph is, in principle, the more logical way to represent the data; but, in practice, SQL usually works better because it's so well tested and refined.

These days I would only reach for a graph DB if I knew for sure I was in one of the very narrow scenarios where SQL just can't do the job. And if that's the attitude of a veteran Neo4j developer, how much luck are you going to have selling the tech world at large?

4

u/BigPinkie Jun 23 '23

Can you elaborate a little on use cases where you would prefer a graphDB? I'm looking at using it for a project that uses the desktop utility only as a way to research relationships in companies data. Wondering if graphDB's are good for scenarios where you don't plan to scale.

3

u/Reasonable_Strike_82 Jun 24 '23

I would look at a graph DB after 1) trying to do the project in SQL, 2) discovering that I simply couldn't make it work, and 3) identifying the cause of the problem as "I am trying to find complex relationship patterns and there are too many joins."

If your end goal is a production system, DO NOT SKIP TO STEP 3. Seriously. Try a SQL database first. I can't tell you how many times I have convinced myself I need Shiny New Technology X, only to realize after a lot of pain that Boring Old Technology Y would have done the job just as well, with a fraction of the time and effort, and spared me endless maintenance headaches.

This has nothing to do with scaling, which has not been a concern on the projects I've worked on. The things that push me away from Neo4j are resource usage (Neo4j is an incredible resource hog), reliability, maintenance, and the lack of a mature ecosystem. SQL has a 33-year head start on Neo4j, with many independent implementations that have been competing for decades, and it really, really shows.

Now, it sounds like you intend to use Neo4j purely for research purposes, it will never be productionalized, and reliability/performance are second-tier concerns. In that case, if you are dealing with a "graphy" problem (looking for complex patterns of relationships in a web of data), it might be worth your time to play around with Neo4j. The Cypher query language makes it simple to formulate some queries that would be very ugly and hairy in SQL, and that could be a compelling argument if you're going to write a lot of ad hoc queries, run them once, and throw them away.

Even so, make sure that you can immediately see a clear benefit from using Neo4j. If you're not sure, stick with the tools you know.

12

u/Immanuel_Cunt2 Mar 25 '22

A huge drawback of Neo4j is that the database is not completely open source. This causes a base reluctance, especially at universities, because it prevents deeper research on the topic. My university professor, for example, said back then that Neo4j is a great database, but important parts are not open source and that's why he won't teach it to us and only teach RDF-based approaches.

0

u/[deleted] Mar 25 '22

[deleted]

2

u/Immanuel_Cunt2 Mar 25 '22

Haven't tried it yet. I'm actually quite happy with Neo4j, considering the ecosystem and documentation, but I'll definitely check it out.

6

u/tjk45268 Mar 24 '22

Drawbacks? New skills required, fewer professionals with graph database experience, limited number of visualization tools with graph (not just chart) visualization features. However, the number of organizations that are successfully delivering graph-based capabilities continues to grow.

2

u/venegr Mar 25 '22

I actually don't quite understand why there are not many graph database professionals even though Neo4j has been in the market for over ten years

2

u/TheOldMancunian Mar 24 '22

If your using something like Spring Data for Neo (was called Object Graph Modelling) then its very easy to learn, build new apps, and get productive. As you say, it is pretty close to a native java object store, but its so much more than that.

Drawbacks - its not MySql. I get a lot of people telling me that unless its <insert favorite RDBMS here> its not real. Once said that in a job interview. Safe to say she did not get the job!

2

u/GioAc96 Mar 24 '22

I actually know Neo4j from university quite well, and I’ve been looking into the Neo4j GraphQL library lately, but haven’t really had the chance to use it on any project. I have to say, I don’t really buy the argument that Neo4j doesn’t take off because it’s not relational, since that didn’t prevent MongoDB from becoming very popular.

How does Neo4j handle horizontal scaling? What about transaction management? I’m asking since I’m struggling to find well written unbiased material on this subject and I haven’t had any experience with Neo4j in real world enterprise applications.

6

u/Meatmow Mar 25 '22

Give the Neo4j GraphQL library a go. Its actually pretty easy to get a GRANDstack app up and running. You can get a free cloud DB with Aura and there are a bunch of YouTube videos from Neo4j about getting it up and running. We use it at our company for one of our internal apps and I love using it. The only downside I see right now is that if you want to use a managed service to host the DB, the base setup is a bit more expensive than other nosql or mysql options.

4

u/subssn21 Mar 25 '22

The only downside I see right now is that if you want to use a managed service to host the DB, the base setup is a bit more expensive than other nosql or mysql options.

I think you hit the nail on the head here. I have been playing with Neo4j for a while now and really like the technology. The deployment options and scaling costs are really scary though.

It seems like Neo4J is really working on this at least for the entry level side with the Aura Free option, but still I can't just go to any region in AWS and create an inexpensive Neo4J instance and get started like I can with MySQL, Postgres, or DynamoDB.

Then once I have built my MVP and start getting customers and have to start paying for Aura, the price ratchets up very quickly and before long you are paying Oracle prices instead of MySQL, Postgres, or DynamoDB prices.

To be fair this is perception from looking at the pricing I have seen/been given for Neo4J and comparing it the MySQL, Postgres and DynamoDB prices and may not reflect what the actual costs are when you start running the production workloads, but if the perceived cost is going to be very high, even if the actual cost is similar, it doesn't matter.

1

u/vagaliki Dec 27 '23

Have you or anyone actually done some calculations on this?

5

u/loradan Mar 24 '22

I think a lot of the problem is simply the prevalence of relational databases. Even NoSQL is built on top of a lot of relational database theory. The prevailing advertising for graph surrounds the importance of relationships. Most people who have been working with databases for a while tend to think of key->foreign key when they hear relationship. So they tend to dismiss the concept. When I first started learning graph databases, my first thought was exactly this. After spending time learning I realized how wrong I was 😁

5

u/Chemical_Quantity131 Jul 14 '22

If you rely on transactions for consistency, then forget Neo4j. It has lots of problems with contention, meaning lots of Deadlocks and wait for locks. On top of that, the performance for certain types of queries suffers as the amount of data grows.

4

u/krilyxid Nov 26 '23

What types of queries suffer?

2

u/wahoohaw Mar 25 '22

I think recent disk speed tech has enabled graph dbs to take off. The amount of data coming off neo4j in my queries binds up on slower disks.

1

u/jakob-k Nov 16 '24

Here is a few practical drawbacks I've come across so far (working with Neo4j):

- In SQL you have foreign keys that can be indexed. So a query that filters a row based on foreign keys are quick and easy to execute. For instance, return all people who work at a specific company AND is part of a specific organization (companyId and organizationId). On the graph, this query results in basically a full scan of all Person nodes, because relationships can't be indexed as such.

- SQL is super declarative which makes it very easy to model using object oriented programming, so we have ORMs available in all shapes and sizes. This is not the case for Cypher, and we end up doing a lot of ridiculous string manipulation. I hate this.

However i feel like I should mention a few upsides as well:

- N+1 and recursive queries are first class citizens of graph databases! Even N+N+N+N+N+1 (etc) queries are extremely efficient.

- Neo4j support custom server-side plugins written in Java. So for queries that are very complex, you can always fall back to writing it in Java. Which means you have support for basic polymorphism, unit and integration testing. This is a ridiculously powerful feature.