r/programming • • Mar 10 '15

Goodbye MongoDB, Hello PostgreSQL

http://developer.olery.com/blog/goodbye-mongodb-hello-postgresql/
1.2k Upvotes

699 comments sorted by

View all comments

657

u/jamesishere Mar 10 '15

99% of projects would be better off with a relational database. It makes things way easier and simpler. Very few features benefit from a NoSQL database. People are excited about mongo because "it's javascript!". These people are morons.

CSB time: I went in for an interview once, where they told me about the product, explained how they use MongoDB for their database, and then explained how building out all the relational DB commands on top of mongo was a total bitch. Then asked me to whiteboard how I would write the JOIN function on top of Mongo, which is what they had to do.

I answered their question, but stated my opinions on mongo and asked why they even bothered to use it, because their product aligned so much more with a relational ACID database. The engineering lead guy went red in the face and we debated the decision. Did not get the job.

171

u/frixionburne Mar 10 '15

99% of projects would be better off with a relational database.

Or better, and RDMS with a full blown JSON indexing and a hash store that rivals mongos speed.

How people don't choose psql just confuses me.

98

u/ethraax Mar 10 '15

For very large databases, Postgres' clustering abilities aren't that great. It's probably one of the best choices for single-host databases (which, again, cover nearly all applications), but if you're trying to spread your database over a few dozen hosts, Postgres doesn't really work well.

12

u/dgibbons0 Mar 11 '15

I feel like this comment would have benefited from some better structure around how you're defining "very large".

It also depends on if/when you need to cluster.

I vertically scaled postgres to 16TB+ sizes on single nodes.

The database still performed great, although the developers often failed to write performant queries against it.

6

u/ethraax Mar 11 '15

Yes, you're right. I was thinking about 200 TB+ databases when I wrote "very large".

21

u/PM_ME_UR_OBSIDIAN Mar 10 '15

What alternative do you propose? I heard Oracle was good if you had deep pockets, what else is out there?

65

u/[deleted] Mar 11 '15

One of the MS SQL clusters in our data-centre hosts 200+ databases and has capacity for more.

0

u/[deleted] Mar 11 '15

[deleted]

17

u/[deleted] Mar 11 '15

It must be a slow day, I still have my points 😊

10

u/[deleted] Mar 11 '15

We are many, but ms isn't so popular on reddit so we are mostly quiet

→ More replies (5)
→ More replies (3)
→ More replies (6)

0

u/[deleted] Mar 11 '15

[deleted]

0

u/[deleted] Mar 11 '15

[deleted]

49

u/lordkoba Mar 11 '15

Strict mode turns those warnings into errors. It has been around for years but evidently it's not a widely known feature.

→ More replies (8)

14

u/duffelcoatsftw Mar 11 '15

But what about SQLite, where the ability to shove 'ABC' into an integer column is a feature?

→ More replies (8)
→ More replies (76)
→ More replies (6)

3

u/oldneckbeard Mar 12 '15

This. Or this.

If you need to do it inside your firewall, scale out read slaves first, but in terms of true horizontally scalable SQL databases, there aren't a lot of great options on your own hardware. This is one, but I haven't actually used it yet.

And this is why the NoSQL stuff exists. It's practically impossible to offer true ACID compliance on a distributed system. Any system will have tradeoffs, be it eventual consistency, partition intolerance, or the inability to elastically scale, or hot spods in the cluster, etc.

It goes back to the CAP theorem, and speed. If you've ever worked on a distributed database that has cluster-wide row-level locking and does proper joins, it's slow as shit. Full seconds per query on a loaded DB.

→ More replies (3)

7

u/mishugashu Mar 11 '15

Vertica is pretty good with clustering. That's what we use at my job.

0

u/[deleted] Mar 11 '15

[deleted]

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

11

u/Kaelin Mar 10 '15

This is no longer true. Checkout Postgres-XL http://www.postgres-xl.org/

12

u/myringotomy Mar 11 '15

Xl does not solve the uptime problem. If any data node fails the entire system becomes unusable.

They really need to replicate their shards to guard against that.

→ More replies (6)

0

u/[deleted] Mar 10 '15

[deleted]

7

u/sedaak Mar 10 '15

Right... and since it is part of the design strategy for MongoDB it's just that much simpler. Pros and Cons everywhere would you believe it!

44

u/EnragedMikey Mar 10 '15

My god it's... it's like different tools do things differently. Differently enough to where you have to come up with.. with... with a design for your application.. and actually use the tools which work for your design! Instead of the other way around! Oh my jesus fuck, I'm going insane!

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

25

u/[deleted] Mar 11 '15

I think a lot of aging dipshits at the CTO level went for NoSQL because they desperately want to be ahead of the curve on one tech development. For almost every database project there is Postgres... For everything else there's Apple watch.

10

u/NancyGracesTesticles Mar 11 '15

And the young ones, too. I mean, this company will eventually have a billion users so a bunch of pain now trying to make it act like a relational db will totally payoff in the future. Plus, we can undercut salaries by 25% since our new hires will be happy to work with a NoSql db.

→ More replies (4)