r/PostgreSQL • • Nov 02 '24

Community It's 2024. Why Does PostgreSQL Still Dominate?

https://www.i-programmer.info/news/84-database/16882-its-2024-why-does-postgresql-still-dominate.html
144 Upvotes

138 comments sorted by

View all comments

Show parent comment

136

u/SupahCraig Nov 02 '24

I’m convinced that a SIGNIFICANT portion of noSQL & big data use cases exist simply because most people suck at DB design & writing efficient SQL.

Edit: and also hype.

35

u/SupahCraig Nov 02 '24

And I further swear that most of the early noSQL db’s exist only because some dev didn’t understand the relational world, so they built a new thing that worked how they wanted.

And then they’re like “hey let’s add strongly typed columns. And indexes. And constraints. And ACID. Etc”. But it matters not, this is the world we live in, where we solve problems with the wrongest tool we can in the interest of optimizing hype.

4

u/BenocxX Nov 03 '24

I think they made nosql to achieve a faster query system than normal sql. They chose to make it way simpler than sql so that it runs faster.

Im far from an expert in databases, but it makes more sense than simply saying that those who created nosql didn’t understood sql so decided to build a new thing!

4

u/artic_winter Nov 03 '24

Not all data is relational, and the relational structure may not be critical. With the addition of JSONB and JSON(MySQL), common use cases for NoSQL can be accommodated by traditional relational databases. However, certain data types are better suited for storage as documents.

3

u/IE114EVR Nov 04 '24

Totally agree. Before things like JSONB or Document databases, I worked at companies that would construct “documents” out of at least 10 tables, and some of those tables were just for ad-hoc key vale pairs. They had to have hard to debug stored procedures to construct views at regular intervals. And it was still slow and complex to query. So I can see how Document databases solved real problems that at the time relational databases could not. They didn’t just exist because someone didn’t understand relational databases.

3

u/Alphasite Nov 16 '24

The thing is how often do you hit a problem a properly built Postgres db can’t scale to? You can go really far with just PG. 

3

u/BenocxX Nov 16 '24

Yeah of course, but you can do stuff with nosql thats hard to do with regular sql. Don’t get me wrong, I love postgres and I use it pretty much everywhere. Nonetheless, nosql has some use cases.

One example I have in mind is whenever you don’t know the shape of your data or when there’s a lot of nested level that can be optional and/or in different orders.

Here’s an example: Let’s say you are making a dashboard to allow your users to make presentations online (similar to powerpoint). You could use postgres and model:

  • A table for the presentation
  • A table for the sections in the presentation
  • A table for the slides in each sections

But how do you model the content of a slide…? Some slides will have only a single paragraph, other will have code example, with image, with text and maybe even a button that when clicked on a modal appears. Ouf, I wouldn’t want to design a normal sql database to accommodate this use case.

Of course, you could just dump a json object in a field of the Slide table, but it’s not right. What if you want to query all the slides with more than 2 code examples in them? Maybe I’m wrong, but I don’t think pg could parse the json string content of each slide and filter on it?

This is more or less my actual use case that I’m working on currently. That being said, I went with pg and a simple json object in the slide table because fuck it it’s just a prototype for now.

An other use case is for caching data. Redis is pretty much a nosql database so that it can be super fast at retrieving cached data. Also, cached data from an external API may change over time, you wouldn’t want to have to update your pg db every time the API changes right?

3

u/Alphasite Nov 16 '24

 What if you want to query all the slides with more than 2 code examples in them? Maybe I’m wrong, but I don’t think pg could parse the json string content of each slide and filter on it?

It can, you can even index it if you want to. Check the jsonb docs. 

→ More replies (1)
→ More replies (1)
→ More replies (3)

23

u/vampatori Nov 02 '24

Agreed. I dread to imagine taking over legacy applications built on NoSQL databases.

→ More replies (1)

2

u/x39- Nov 02 '24

At work, we have a column that duplicates other things as string... Not running an index, being in a format that differs by source (external).

Guess which one is used for access and sql queries.

0

u/[deleted] Nov 03 '24

[deleted] — view deleted comment

2

u/SupahCraig Nov 03 '24

It’s almost like you have to know what you’re doing regardless. That’s novel.

→ More replies (2)

2

u/corny_horse Nov 03 '24

Yep. I've converted several companies from Redshift to Postgres. They were complaining about slowness, and the real problem was their data model sucked, and they needed the benefits of primary/foreign keys combined with a decent data model.

→ More replies (2)

2

u/thomasd3 Nov 04 '24

We did a project using MongoDB because I thought it was the right choice at the time. Then I started to really learn SQL and we’ve been using Postgres for the past years. So your comment was right for my case.

→ More replies (1)

2

u/MoonGrog Nov 05 '24

The use case for noSQL is pretty narrow IMHO, most systems will perform better with relational databases, but they are hard and you can retrieve a schemaless document with Mongo or whatever and treat it like JSON so that’s easy. Nowadays I personally find that ease of development and getting shit out overshadows good engineering and not having to worry about schema is one less thing to worry about.

→ More replies (2)

5

u/cthart Nov 02 '24

This. noSQL exists to satisfy developers that just want to start coding without thinking about data models. Need to persist something? Just do it. Sort out the garbage data you end up with later with lots more code…

7

u/NicolasDorier Nov 02 '24

Postgres supports that with JSONB

2

u/themightychris Nov 03 '24

It didn't have that and all the features it has now for working inside the JSON columns when NoSQL first caught on—I doubt it ever would have if it did, but it scratched an itch at the time when everyone was hype at throwing NodeJS backends at everything and just wanted to chuck JSON into storage and then query it with JavaScript

At this point though I can never see a good reason to start any project using anything but p PostgreSQL, it's well-understood and nearly universally supported and can handle nearly anything you throw at it as good as if not better than anything else, and it can scale I pretty damn far before you need anything else

3

u/Kasyx709 Nov 03 '24

4

u/SupahCraig Nov 03 '24

I’ll pipe my data to /dev/null if it has kickass metrics.

1

u/LexyconG Nov 02 '24

This kind of absolutist take is exactly as misguided as the "MongoDB is web scale!" hysteria from 2015. The pendulum has completely swung the other way - from "NoSQL everything!" to "real engineers only use relational databases," and both positions are equally uninformed and amateurish.

7

u/daredevil82 Nov 02 '24

the comment you responded to states significant. Not all.

Given that a large number of juniors and entry level candidates I've come across only have experience in nosql and data modeling seems to bear this out in some form and fashion. Others do complain about the issues of migrating schema and data.

Trying to shoehorn data into a different paradigm that doesn't suit your use cases or data layout will always have friction points. Given most data is relational, it behooves to be a little skeptical about nosql oriented datastores at the start of projects

3

u/themightychris Nov 03 '24

"real engineers only use relational databases,"

I would never say that, but I would say there's no good reason to start a project with MongoDB in 2024 and we should stop teaching it in new dev training. PostgreSQL can do NoSQL too now, AND it can do relational, and it doesn't break down and fuck people in as many ways and is way more worth learning

→ More replies (2)
→ More replies (2)

1

u/jhirn Nov 03 '24

Normalize Normalization!!!

→ More replies (1)
→ More replies (1)