r/ProgrammerHumor • • Mar 25 '20

Meme Its a win-win situation

Post image
55.1k Upvotes

529 comments sorted by

View all comments

Show parent comments

109

u/nishinoran Mar 26 '20 edited Mar 26 '20

Mongo DB is web scale, it has sharding.

I hear piping data to /dev/null might scale even better though

64

u/mecataylor Mar 26 '20

I’ve never used Mongo, but I have sharded before. Does Mongo have a function to change its pants?

35

u/[deleted] Mar 26 '20

People like to joke about MongoDB, but this is actually a good use case for a sharded noSQL database like MongoDB. Due to the consistency model of most SQL databases it can be hard to get enough write throughput to satisfy the requirements for a website with lots of users.

0

u/[deleted] Mar 26 '20

[deleted]

0

u/[deleted] Mar 26 '20

[deleted]

4

u/karmahorse1 Mar 26 '20

That entire article is about how MongoDB didn’t work well with that developers very specific and predefined data structure, and many of his complaints appear to be about things that are inherent to every NoSQL dB not just Mongo.

MongoDB is a perfectly fine database. It’s true it does have scaling issues if you’re dealing with massive data sets, but for most people it’s tooling alone makes it worthwhile.

3

u/i-am-stoic Mar 26 '20

I worked with mongo for a couple years at my last gig and recently started a new one where we're on sql. I'm having trouble going back - feel like I stepped back in time

1

u/Extract Mar 26 '20

For many people, Mongo is the main (sometimes only) NoSQL database they'll ever use. Yes, it's an object-based scheme problem in general, not just Mongo - you can substitute it in your mind when reading if you want.
And no, it's not a NoSQL problem, since NoSQL also includes stuff like GraphDB, and many other schemas that just aren't standard SQL.

1

u/karmahorse1 Mar 26 '20

I'm not claiming MongoDB is the right DB for everyone and every problem. But it is a perfectly good to DB for both people new to to NoSQL, and projects that don't have overly complex data architectures and don't have to worry about scaling to support a Facebook amount of concurrent users.

My stack for my current startup utilizes a mixture of MongoDB and Redis for its primary user storage and it's proven extremely efficient. This whole "MongoDB is bad" joke is stupid and misleading.

2

u/Saladtoes Mar 26 '20

Thanks for the read. I was feeing kind of bad that I have been shoving lots of loose-schema’d JSON into columns in my MSSQL server. Still feels wrong, but I feel affirmed that Mongo would be wronger for my case.

5

u/karmahorse1 Mar 26 '20

That article is garbage. MongoDB is perfectly adequate for the vast majority of users. If you don’t want to use Mongo go with another NoSQL database, but please stop storing stringified JSON data in your SQL columns.

2

u/AWildIndependent Mar 26 '20

Wait why are people storing JSON strings? What use case does that solve o.O

2

u/karmahorse1 Mar 26 '20

My guess is to store flexible data that doesn’t adhere to a strictly defined schema. So, exactly the problem NoSQL was created to solve.

1

u/AWildIndependent Mar 26 '20

Oh i see what you are saying.

I pity anyone who actually does that. Insanity lol

→ More replies (11)

1

u/Saladtoes Mar 26 '20

It’s either have two different databases or use SQL Servers provided JSON functions. I don’t see a strong reason to use two databases.

1

u/Extract Mar 26 '20

Don't listen to that other guy, you are correct (as much as once can be correct in a partly subjective matter).
Like the other guy said, Mongo is adequate for storing object-like data, but you'd need both SQL and Mongo (or other object-based* DB) if you have both types of data, and having 2 databases is very rarely worth the performance (well, unless you count something like Redis as a NoSQL DB, even though it's just a simply object-based* cache).

* Notice that I write object-based, not object oriented, as Mongo is not an OODB

1

u/karmahorse1 Mar 26 '20 edited Mar 26 '20

I don't know his usage case, but generally speaking if you hear someone is storing stringified JSON data in SQL, theres a good chance they're doing something wrong.

If he's just storing small blobs of data to pass directly onto the client that's fine (though he should probably be encoding it first).

But if he's using it to represent a parent-child relationship, he needs to move that data out into a separate table and join on it instead, as storing data in JSON blobs takes up a lot more space and won't allow you to index on, or partially select any of the subfields.

If he doesn't want to put the data in a separate table as it doesn't have a strongly defined schema attached to it, then SQL probably isn't the right solution altogether.

As you say, Redis can be a good second option in the cases where you want to combine both object based and relational based storage formats. Even if it requires multiple queries, it'll still likely be faster than having SQL read large amounts of JSON off of disk.

1

u/Extract Mar 26 '20

But.. you do realize not all data that has a parent child relationship needs to be indexed, nor operated on in any way other than being displayed as additional data when a SINGLE object is queried?

Of course, parent-child relations are generally one-to-many tables, but very often a single row will have a lot of not-that-important data which only needs to be displayed when that object is queried directly, and never searched by (example - non-technical description of products).

Sure, indexed data deserves its own columns (and sometimes tables), but we were talking about data that could be placed either into MongoDB or a JSON string - relation data was never in this question to begin with.

And sure - JSON strings "waste" space, while blobs "waste" performance with encoding/decoding - however, if you're storing data in a JSON string/blob that's important enough for the space or lost performance to matter, you should've stored it in its own column/table to begin with.

3

u/LargeHard0nCollider Mar 26 '20

Discord doesn’t use mongo, but their database architecture is very similar to what you describe, and they call out the same design considerations in this article

https://blog.discordapp.com/how-discord-stores-billions-of-messages-7fa6ec7ee4c7

0

u/[deleted] Mar 26 '20

[deleted]

2

u/LIL-BAN-EVASION Mar 26 '20

Mongo supports multi document acid transactions

This essay is based on a several years of discussions, looking through numerous blog posts/presentations, and reading approximately 3,000 HN comments

Lmao

1

u/kyay10 Mar 26 '20

The /dank/null can hold much, much more tho.

1

u/CaptainAwesome8 Mar 26 '20

Huh...I don’t remember this part of the new Animal Crossing...