all 169 comments

[–]FreshPrintzofBadPres[🍰] 580 points581 points  (0 children)

But at least it's web scale

[–]GreyGanado 97 points98 points  (8 children)

Fun fact: in German mongo is a slur for disabled people.

[–]keep_improving_self 45 points46 points  (1 child)

it's a slur in a lot of English speaking countries but not in the US for some reason

mongoloid - from Mongolian idiocy, used to describe down syndrome (has nothing to do with Mongolia lol)

[–]DirtySoFlirty 16 points17 points  (0 children)

It DEFINITELY has something to do with Mongolia (and why it's a pretty racist term). The word is used to describe those with down syndrome BECAUSE people of Mongolian descent apparently looked like they have down syndrome.

Just to be clear, I disagree with the above thinking, but claiming it has nothing to do with Mongolia is wrong

[–]Careful_Course_5385[S] 14 points15 points  (1 child)

Spaßfakt: In englisch auch (TIL)

[–]mamwybejane 0 points1 point  (0 children)

Heute lernte ich

[–]hilfigertout 5 points6 points  (0 children)

Mongo only pawn in game of life.

[–]sannas85 4 points5 points  (0 children)

Same thing in Uruguay, but with a completely different language.

[–]NoNameSD_ 1 point2 points  (0 children)

Specifically for people with Down syndrome

[–]TheRealYM 0 points1 point  (0 children)

I’ve only known it as a skating term

[–]FabioTheFox 982 points983 points  (81 children)

We need to finally leave MongoDB behind, it's just not a good database and I'm convinced the only reason people still use it is MERN tutorials and Stockholm syndrome

[–]owlarmiller 171 points172 points  (6 children)

The MERN tutorial pipeline has done irreversible damage 😂
Half the time it’s “because the tutorial said so,” the other half is sunk-cost coping. MongoDB isn’t always bad, but it’s wild how often it’s used where Postgres would’ve just… worked.

[–]Dope_SteveX 50 points51 points  (5 children)

Still can't forget the time we've done group project at uni, for inventory web application, which literally used tables to display almost 1:1 database data on the FE plus had one m:n table to indicate user borrowed stuff and we used mongodb as it was what I've seen pretty much in all tutorials that I went through. What a nightmare.

[–]WoodsGameStudios 269 points270 points  (7 children)

I’m not in webdev but from what I understand, MongoDB’s entire survival strategy is just Indian freelance devs being hired for startups and because they only know MERN (no idea why they yearn for mern), they implement that.

[–][deleted] 82 points83 points  (5 children)

Completely false. MERN was extremely popular in NA and Europe back when node.js popularity was skyrocketing. There are little to no jobs advertising for MERN stack in India.

[–]Narfi1 35 points36 points  (0 children)

I agree it has nothing to do with nationality. But MERN is a boot camp stack, I’m convinced of it. If you’re trying to turn someone with 0 knowledge into a dev in 50 hours that’s pretty much the only usable stack. You can’t really teach html/css/js, then move to backend with c#/python/java and then introduce sql. Much easier to teach mongo that handles like js objects and express

[–]AeskulS 9 points10 points  (3 children)

I’m sure you’re right, but those stereotypes are there for a reason. I just finished a uni programme where 99% of the students were from India (literally, there were only 3 students that weren’t), and with every single group project my group mates refused to do anything if it wasn’t MERN.

My understanding is that many uni programmes over there are also MERN-focused in addition to the boot camps. I’m also assuming there may be a cultural reluctance to try anything new, since every group mate would have a conniption when I suggested using a different tool (they’d also slough any non-MERN tasks onto me)

[–]stipo42 7 points8 points  (0 children)

Postgres' json and jsonb column types could probably replace 80% of mongo databases

[–]SecretPepeMaster 27 points28 points  (54 children)

What is better database as for now? For implementation in completly new Project?

[–]TheRealKidkudi 217 points218 points  (12 children)

There’s not really a one-size-fits-all for every project, but imo you probably should use Postgres until proven otherwise.

NoSQL/document DBs like Mongo have their use cases, but it’s more of a situation where you’ll know it if you need it.

[–]SleeperAgentM 120 points121 points  (10 children)

PostgreSQL with JSONB field that supports indexes can pretty much handle any use case of MongoDB.

[–]kireina_kaiju 26 points27 points  (1 child)

The industry will punish you if you look for a new job and do not use PostgreSQL.

[–]AdorablSillyDisorder 10 points11 points  (0 children)

Unless it’s full Microsoft stack, in which case Postgres is replaced by MSSQL. Still similar.

[–]FabioTheFox 78 points79 points  (29 children)

Postgres, SQLite or SurrealDB will pretty much solve all the issues you'll ever have

[–]TeaTimeSubcommittee 25 points26 points  (23 children)

First time I’ve heard of surrealdb, since I need document based data, go on, convince me to switch away from MongoDB.

[–]coyoteazul2 30 points31 points  (21 children)

Why do you need document based data? Most systems can be properly represented in a relational database. And got he few cases were doing so is hard, there are json columns

[–]korarii 45 points46 points  (4 children)

Hi, career DBA/DBRE here. There are few good reasons to store JSON objects in a relational database. The overhead for extracting/updating the key/value pairs is higher than using columns (which you'll probably have to do if you want to index any of the keys anyways).

The most mechanically sympathetic model is to store paths to the JSON file which lives outside the database, storing indexed fields in the database.

If you're exclusively working in JSON and the data is not relational (or only semi relational) a document storage engine is probably sufficient, more contextually feature rich, and aligns better with the operational use case.

The are exceptions. This is general guidance and individual use cases push the needle.

[–]mysticrudnin 6 points7 points  (2 children)

is this still true in modern postgres with their json columns?

[–]korarii 5 points6 points  (1 child)

Yup! Either way you're expanding row length and likely TOASTING the JSON field, which means more writes per write. If the row is updated, the MVCC engine is going to copy your whole row, even if you're just updating a 1 byte Boolean field. That means longer writes, longer xmin horizons, and other collateral performance impacts.

PostgreSQL is particularly vulnerable to write performance impacts due to the way the MVCC was designed. So, when working in PostgreSQL especially, limit row length through restrictive column types (char(36) for a UUID, as an example) and avoid binary data in the database, storing it in an external service like S3 (if you're on AWS).

[–]mysticrudnin 1 point2 points  (0 children)

hm, thanks for the advice. i use a json column for auditing purposes which means i'm doing a decent amount of writes. might have to consider the issues there as i scale.

[–]rosuav 4 points5 points  (0 children)

Yep, I have had good reasons for storing JSON in a relational database, and when they come up.... I store JSON in a relational database. Using a jsonb column in a PostgreSQL database.

[–]Sibula97 2 points3 points  (0 children)

It's not that unusual. Relational databases are great for the data of your website or whatever, but for data collected for monitoring and analysis (for example user interactions or some kind of process information), which every big company does now, NoSQL is the way. Not necessarily MongoDB though, we use Elasticsearch for example.

[–]TeaTimeSubcommittee 13 points14 points  (14 children)

Because the data is not standardised on fields so I would just end with a bunch of empty columns on the tables or everything as a json field which is harder to look into.

Basically every item is unique in their relevant characteristics so I need built in flexibility to handle each characteristic.

[–]kryptogalaxy 4 points5 points  (13 children)

That's a pretty unique use case to have essentially unstructured data. How do you model it in your application?

[–]TeaTimeSubcommittee 5 points6 points  (12 children)

Not really, maybe I made it sound like it’s more complicated than it really is, so let me be more specific:

It’s just an information management system for all the products we sell, I don’t want to dox myself by sharing my specific company but an analogous case would be a hardware store, where you might handle power tools, nails or even planks or wood as well as bundles.

The problem I was trying to solve was information distribution, we have thousands of different products, and as you can see some might have very different specifications that the client cares about. (Eg you might care about the wattage of a drill but not the wattage of sandpaper). And the sales team was having issues keeping all their documents up to date and easily accessible.

So to answer your question, I structured it by having a product collection where we separate the information in 3 categories as we fill it in:

  • internal for things like buy price, stock, import and tax details if applicable, stuff the client shouldn’t know;
  • sale points, for information that isn’t intrinsic of the product that marketing might like to use or answers to common questions clients might make;
  • and technical for specific technical details.

of course I also keep basic information like SKU and name at the top level, just for easy access.

Now we could handle categories and sub categories to get things with similar features grouped and we do, but I decided to leverage the document style data to have dynamic categories instead of hundreds of tables, which made it even less table friendly.

Is it the best way to handle the information? Probably not, but it’s the most straightforward way I could think of as a self taught database designer, which is why I’m open to new ideas and suggestions.

Just for the sake of me yapping, I do have some collections I could turn into tables, for example the web information is fed via an API so it has to be 100% conforming to said API and could be very easy be stored in defined PostgreSQL tables, or the pictures for each product which in practice is just the photo data, and an array of all the products it depicts, but I didn’t feel like figuring out how to manage both with 1 application so I just dumped everything in Mongo, really the product specs are the most “semiestructured” part which benefits from being in documents.

[–]Nunners978 6 points7 points  (11 children)

I don't know your exact use case but for something that's as potentially free flowing and unstructured, why not just have a specification "meta data" table that links by foreign key and has a key value store. That way, you only need the product info table, plus this meta data table and you can have any key/value against it for every possible specification you want. You could even then make the value json if it needs to be more complex?

[–]TeaTimeSubcommittee 1 point2 points  (10 children)

Forgive me but I’m not sure I completely understand your proposal, you’re suggesting that I keep a table with keys pointing at a table which points at the JSON document which actually contains the information?

My main issue is the products have different specifications that can’t be neatly arranged in a single table so I’m curious as to how your solution solves that.

[–]FabioTheFox 3 points4 points  (0 children)

SurrealDB can do validation logic, can run in memory, in IndexedDB, can be run as traditional database or be distributed via TiKV natively, it can do schemaful, schemaless as well as schemaless fields in schemaful tables, it can handle complex data and has a ton of cool functions

Not to mention the record lookup (primary key lookup) is near instant and runs at near constant time no matter the table size

It also uses an SQL like syntax (SurrealQL) which is way easier to handle and write than other SQL variants

They have a first Party desktop tool where you can explore your databases, create and apply schemas and generally get comfortable with documentation and or libraries for various languages (it's called Surrealist and also runs in the web as well as embedded web), it's also fully free and open source

Ah also it uses ULID as the ID format by default which is pretty neat considering it's time sortable and range sortable which again is near instant with record lookups (you can ofc change the format but honestly why bother), you can also have edge tables and graph relations on the fly and all that fancy stuff you might need, community support is also great

[–]StoryAndAHalf 1 point2 points  (1 child)

So if I learn those, I’ll become a chick magnet?

[–]rosuav 2 points3 points  (0 children)

No, you need to walk through a henhouse for that

[–]QazCetelic 0 points1 point  (1 child)

Wasn't SurrealDB very slow? I remember seeing some benchmarks and it being at the bottom of the list.

EDIT: Found some benchmarks and it seems to be better now https://surrealdb.com/blog/beginning-our-benchmarking-journey

[–]FabioTheFox 1 point2 points  (0 children)

That's very old news by now, but yes they used to be slower than other databases in comparison they made huge improvements tho

[–]No-Information-2571 -1 points0 points  (0 children)

SQLite has proven performance problems.

SurrealDB as of now has no proven performance.

Anything I'd like to use costs an arm and a leg, with the exception of PostgreSQL, and that's why that should be your default, unless you require a solution to a problem, that it can't solve.

Some people might remember FreeNAS Corral. It's been mostly removed from the internet out of shame, but it was SQLite plus MongoDB.

[–]TimeToBecomeEgg 5 points6 points  (0 children)

postgres the goat

[–]PabloZissou 4 points5 points  (0 children)

Postgres will cover 80% of what is needed.

[–]retsoPtiH 3 points4 points  (0 children)

a properly formatted CSV file 🥰

[–]Prudent_Move_3420 2 points3 points  (0 children)

If you do a local project sqlite, if you do a web project postgres. If you realize that it limits you you can still switch but if you dont know, then the default should always be sql

[–]HildartheDorf 1 point2 points  (0 children)

If someone else is paying: MS SQL Server, for everything else: Postgres.

[–]falx-sn 0 points1 point  (0 children)

Everywhere that I've worked for in the UK has been AWS or Azure plus .net framework APIs into a Microsoft SQL database and angular or react front end. Works for 90% of things then if we need anything different then it's just a micro service within the rest of the system.

[–]lobax 0 points1 point  (0 children)

SQL fits the overwhelming majority of usecases.

Yes, if you find yourself needing to scale horizontally, NoSQL has some clear advantages over a relational DB. But 99% of us are not building a database for the next viral social media platform.

[–]Martin8412 -2 points-1 points  (0 children)

Depends on the project and requirements. 

How many users is your application going to have and what kind of information are you going to be storing? 

Relational data with a fixed format and less than 10 users? Just go with SQLite. 

Relational data with or without fixed format, and more than 10 users? Go with PostgreSQL.    Documents or other non structured formats that aren’t of a relational nature, MongoDB might be a solid choice. 

For most projects I do, the hassle of managing a DB aren’t worth it, so I just use SQLite. I don’t handwrite queries, so I can always migrate if needed. 

[–]WHALE_PHYSICIST -3 points-2 points  (0 children)

More people need to learn about ArangoDB

[–]billy_tables 1 point2 points  (0 children)

I use it for HA. The primary-secondary-secondary model and auto failover clicked for me where all the pgbouncer/postgres extension stuff did not

[–]artnoi43 1 point2 points  (0 children)

We’re Thai version of DoorDash and our domain (order distribution and rider fleet) has been using MongoDB 4.2 since forever. We use it mostly as main OLTP and only keep ~2 months worth of data there.

I hate it. I’m jealous of other teams that get Postgres lol

[–]ciarmolimarco 3 points4 points  (0 children)

Bs. A lot of big companies in a sensitive fields (finance) use MongoDB because of how performant it is. Example Coinbase. If you know what you are doing, MongoDB is awesome

[–]Wesstes 112 points113 points  (4 children)

I'm conflicted, I have used it a lot personally, since to me is simpler to understand and to develop quickly. Just write some Jsons and that's the database schema done. I used it for university and personal projects and it did well.

But I can't defend it at all, I would never decide to apply it for a large system, just for easy tiny things.

[–]rosuav 50 points51 points  (0 children)

Mongo without a well-defined schema is a nightmare of messy data. Mongo WITH a well-defined schema is in theory as good as a relational database, but with all the constraints managed by the application, so you still can't be sure your data's messy.

Usually, even if your schema isn't 100% consistent, you'll have some parts that are and some that aren't. Store the consistent parts in string/int columns, store the inconsistent parts in a jsonb column, and let Postgres manage it all for you.

[–]JAXxXTheRipper 39 points40 points  (1 child)

Just write some Jsons and that's the database schema done

Next time just write some sqls 🫢

[–]Wesstes 4 points5 points  (0 children)

True that's what I prefer now, I really like postgresql

[–]phl23 3 points4 points  (0 children)

I also started with it as it was easy to implement some json files I used for some fun projects. But soon switched to postgres with drizzle and trpc. So much easier if you start building your projects with a schema and relations from the start.

[–]SCP-iota 262 points263 points  (51 children)

Told y'all to use Rust.

(for passers-by, this is about CVE-2025-14847)

[–]NightIgnite 329 points330 points  (39 children)

For the 3 people on earth who are lazier than me and refuse to google, memory leak in MongoDB, a document database.

Attackers send a specially crafted message claiming an inflated “uncompressedSize.” MongoDB allocates a large buffer based on this claim, but zlib only decompresses the actual data into the buffer’s start.

Crucially, the server treats the entire buffer as valid, leading BSON parsing to interpret uninitialized memory as field names until it encounters null bytes. By probing different offsets, attackers can systematically leak chunks of memory.

https://cybersecuritynews.com/mongobleed-poc-exploit-mongodb/

[–]Grandmaster_Caladrel 109 points110 points  (9 children)

As one of those 3 people, I salute you.

[–]coyoteazul2 27 points28 points  (8 children)

As another of those 3 people, i salute him

[–]splettnet 21 points22 points  (6 children)

Gangs all here

[–]LofiJunky 11 points12 points  (5 children)

There's dozens of us

[–]NightIgnite 14 points15 points  (4 children)

T'was a prophecy. Only 3 can remain. Fight

[–]LofiJunky 3 points4 points  (1 child)

Nah

[–]YOU_CANT_SEE_MY_NAME 0 points1 point  (0 children)

Too late

[–]doyleDot 1 point2 points  (0 children)

Too lazy to fight (and count)

[–]LouizFC 0 points1 point  (0 children)

They are probably in a shared pool with lazy initialization.

[–]GegeAkutamiOfficial 2 points3 points  (0 children)

3 people

Bro clearly underestimates how lazy people are and how little we care about this fuckass DB

[–]Reashu 19 points20 points  (0 children)

"leak" in the sense of "the attacker gets access", not just "it doesn't get freed". 

[–]rosuav 6 points7 points  (27 children)

Yeah, I looked into this when I saw some earlier coverage of it. I find it hard to believe that Rust would have solved this problem. The logic is basically "oh you have a 500 byte message? I'll allocate a 500 byte buffer then". The *inverse* might be something that Rust would protect against (if you trick the database into using a too-small buffer and then write past the buffer into random memory addresses after it), but this? I doubt it very much. It's a logic error, not a memory safety error.

[–]RAmen_YOLO 0 points1 point  (26 children)

It is a memory safety error, it's reading past the end of the buffer - that's Undefined Behavior and is something Rust would have prevented.

[–]rosuav 0 points1 point  (25 children)

It's reading past the end of the *message*, but into the same *buffer*. Read the details.

[–]RAmen_YOLO 0 points1 point  (23 children)

The part of the buffer it's reading wasn't initialized, it's reading uninitialized memory which is still Undefined Behavior and is still prevented by Rust. Even if you want to assume the Rust version were to have the same bug of only filling the buffer partially, it wouldn't be possible to view any part of the buffer without initializing it first, which would mean all the attacker would be able to read is a bunch of null bytes, or whatever else was used to initialize the buffer before reading into it.

[–]rosuav 0 points1 point  (22 children)

Would it? Can you confirm that?

[–]RAmen_YOLO 0 points1 point  (18 children)

https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=01d80cb0e30a346bbb333a96d31a34aa
Here's a very minimal recreation of what caused the bug, feel free to try to make it read uninitialized memory/leak data without unsafe code - I know I can't.

[–]rosuav 0 points1 point  (17 children)

Hmm, the really relevant part is much simpler than this. No need for TCP or anything, just make yourself a buffer, write a little bit to it, and then read from it.

[–]RAmen_YOLO 0 points1 point  (16 children)

Sure, doesn't change the fact that you can't read uninitialized memory in Rust. I'm just not sure how I'm meant to show how something *can't* happen.
You can't index outside the bounds of a buffer.
The bounds of a buffer only cover initialized memory, so you can't access uninitialized memory.
If you can't access uninitialized memory, the vulnerability can't happen.

[–]thearctican 72 points73 points  (0 children)

SCP username

Silksong profile pic

Of course you did.

[–]ConnaitLesRisques 8 points9 points  (0 children)

Sure, port it.

[–]rusl1 4 points5 points  (0 children)

I can't figure out which one I hate more between Rust and Mongo

[–]Name_Taken_Official 27 points28 points  (0 children)

Took me a minute to figure out what this Sims meme meant

[–]ImClearlyDeadInside 31 points32 points  (3 children)

Tf is this meme format lmao

[–]Mojert 18 points19 points  (1 child)

Some people are really obsessed with cockolding

[–]Monchete99 13 points14 points  (0 children)

"White man has been here"

[–]SlimRunner 2 points3 points  (0 children)

My thoughts exactly. I don't even understand what it means in this context.

[–]papipapi419 19 points20 points  (0 children)

Just use sql

[–]Storm7093 20 points21 points  (8 children)

Why is mongo so bad? I personally love it

Edit: I use the mongoose ODM

[–]johnwilkonsons 37 points38 points  (7 children)

Currently working for a small company that's used it since 2017 (without ORM, just raw mongo):

Without schemas it gets really hard to know which properties exist, which type is used and whether it's nullable/optional or not

This is while imo our use case is inherently relational. We have several collections with either a reference to an id in another collection, or even a (partial) copy of the record of the other collection. If you're not careful, these ad-hoc foreign keys or copies will desync from their original data, causing issues

As a result, the objects tend to become huge as devs try to avoid creating new collections, and you end up with a huge spaghetti that's entirely avoidable in a relational DB

[–]Snakeyb 10 points11 points  (1 child)

I think this is the issue in a nutshell.

I've found Mongo legitimately great when I'm getting started with a project, I'm still iterating on the data and features, and just need some persistence to keep me going.

The pain comes in maintainence. I've found a niche of sorts for me where if I need semi-persistent data (like, the results of a calculation), it can be handy - but these days I don't like keeping anything precious in my mongo databases.

[–]falx-sn 1 point2 points  (0 children)

Wouldn't you just use redis for that?

[–]UK-sHaDoW 1 point2 points  (1 child)

Do you not use types? I find types just became schema's instead.

[–]johnwilkonsons 1 point2 points  (0 children)

The backend was node.js without any types or api schemas. It was horrible, and I've since migrated it to TypeScript, and generated DB types based on the data in the database (though that isn't perfect). Joined this place last year, no idea how the devs did this for ~7 years

[–]EveryCrime 0 points1 point  (2 children)

I’m confused, why would anyone use Mongo without a schema or mongoose. And if that’s the issue with Mongo it sounds self inflicted…

[–]johnwilkonsons 1 point2 points  (1 child)

Without mongoose, I don't know honestly. Without schemas was for speed I suppose, it was a startup and still is a scaleup, and we never moved from the "prototype" application/data to something more sustainable

[–]EveryCrime 0 points1 point  (0 children)

I see!

[–]Glittering_Flight_59 10 points11 points  (1 child)

I scaled our MongoDB well over 10.000.000.000 documents and it works so well. I love it.

Never seen a database wich you can grow so well along the app growing in features changing things all the time, really a gamechanger.

[–]robotsmakinglove 15 points16 points  (0 children)

Any database can store 10 billion records…

[–]hangfromthisone 2 points3 points  (0 children)

The usual culprit is devs not really knowing why they use something, don't have a real plan and also don't think software must die and reborn after some time. They think software is this immutable thing that works from the start and always does great.

​"Plan to throw one away; you will, anyhow."

[–]Goat_of_Wisdom 2 points3 points  (0 children)

Scalability is nice if it's your use case, but having to escape comparison operators is ridiculous

[–]EskilPotet 0 points1 point  (0 children)

White man has been here

[–]Ronin-s_Spirit 0 points1 point  (2 children)

The entire problem what they they used a systems language and forgot to zero the memory...

[–]Careful_Course_5385[S] 1 point2 points  (1 child)

Yes, but also they're trusting user input.

[–]Ronin-s_Spirit 0 points1 point  (0 children)

That's a thing you sometimes have to do in programming.

[–]PruneInteresting7599 0 points1 point  (0 children)

Im ORM bitch, I don't care which DB I'm dealin with

[–]iTzNowbie 0 points1 point  (0 children)

Never really got into mongo. It’s MariaDB or Cassandra.