News for hackers. Stuff that matters.
Re:Ask HN: Do you still use MongoDB? by josephg on Friday May 22, 2020 @07:28AM (#23270912)
No. Every time I've used mongodb we've ended up regretting it for one reason or another. And migrating to a different database after launch is a huge hassle.

I've done a couple projects where we kicked off with postgres using JSONB columns for early iteration. Then we gradually migrated to normal SQL columns as the product matured and our design decisions crystallized. That gave us basically all the benefits of mongodb but with a very smooth journey toward classical database semantics as we locked down features and scaled.

Re:Ask HN: Do you still use MongoDB? by heliodor on Friday May 22, 2020 @09:02AM (#23271556)
Yep, just regret and misery.

Back in 2010 when the MongoDB hype was high, the well-known company where I was working at the time decided to build the next version of the product using MongoDB. I was on the analytics team and had to code a whole bunch of intricate map-reduce jobs to extract summary data out of Mongo. I'd repeatedly head to the product team and ask them to explain the edge cases I was seeing in the data and they would not be able to give me an answer because the data was on the third or fourth version of their mentally-stored schema and no one knew anymore. All in all, misery.

Re:Ask HN: Do you still use MongoDB? by xellisx on Saturday May 23, 2020 @09:38AM (#23282831)
I decided to check out the hype back then, and started writing tutorials on using PHP with MongoDB. After the 3rd posting, I realized that they were all about being anti relational, and though you you could have keys to other records in your record. This lead to bringing back records, querying more records, then manually filtering records,rinse and repeat.

Iirc, they've turned around on their anti relational views and now allow for joins.

I looked at OrientDB awhile back ago, but it fell flat with the lack of features and oddness.

If I had more time, I would really dig into ArangoDB.

Re:Ask HN: Do you still use MongoDB? by tmlee on Friday May 22, 2020 @09:52AM (#23272048)
While there are many people here who are sharing their bad experience with MongoDB, just curious if you all find the experience with DynamoDB similar?

Since they are both of the NoSQL family.

Re:Ask HN: Do you still use MongoDB? by danenania on Friday May 22, 2020 @12:51PM (#23274137)
DynamoDB is a lot more explicit about its tradeoffs. Much of the backlash against Mongo was because it basically claimed to be well-suited to any use case, when its sweet spot was really far narrower. To be successful with Mongo, you need to design the entire app around its limitations, but those limitations were initially downplayed and obscured.

People were convinced that Mongo was a good choice as a default, general purpose db, when it clearly wasn’t for about a million reasons.

I don’t think DynamoDB is marketed or viewed in the same way. The docs are pretty clear about needing to design your data model to specifically work well with Dynamo. People using it seem to generally be aware of its limitations, and deliberately choose to accept them for the sake of performance and scalability. At least that’s my perception.

Re:Ask HN: Do you still use MongoDB? by rumanator on Friday May 22, 2020 @09:16PM (#23278921)
> I don’t think DynamoDB is marketed or viewed in the same way. The docs are pretty clear about needing to design your data model to specifically work well with Dynamo.

More importantly, AWS is very explicit in letting newcomers be perfectly aware that DynamoDB's usecases are, that they are very specific niche use cases, and that if users require schemas and joins then they should just stick with either relational databases or graph databases.

Those who overpromise will always disappoint.

Re:Ask HN: Do you still use MongoDB? by hartror on Friday May 22, 2020 @06:11PM (#23277648)
What are those good use-cases for mongo?
Re:Ask HN: Do you still use MongoDB? by danenania on Sunday May 24, 2020 @01:33AM (#23289375)
Basically when speed and horizontal scalability are very important, and consistency/durability are less important. It’s also pretty good for unstructured or irregularly structured data that’s hard to write a schema for.

Web scraping or data ingestion from apis might be a reasonable use case. Or maybe consumer apps/games where occasional data loss or inconsistency isn’t a big deal.

It can also be used effectively as a kind of durable cache (with a nice query language) in place of redis/memcached if you give it plenty of ram. While its guarantees or lack thereof aren’t great for a database, they’re pretty good for a cache.

Re:Ask HN: Do you still use MongoDB? by jaydestro on Friday May 29, 2020 @09:18AM (#23349626)
I worked for a big news website- we used mongodb for pixel tracking data.

I went on to work at mongodb

Re:Ask HN: Do you still use MongoDB? by garethmcc on Friday May 22, 2020 @11:03AM (#23272837)
DynamoDB is a completely different beast and would use no other data store unless I had to. It can pretty much handle any transactional workload I need.

It's cheap, its fast and it scales super high. Don't need much more

Re:Ask HN: Do you still use MongoDB? by electricEmu on Friday May 22, 2020 @12:34PM (#23273914)
DynamoDB is consistent and scalable, not fast and cheap.

DDB is great for storing data that is required to be scalable and never needs to be joined. Add in DAX, developer time necessary to orchestrate transactions, calculate the scaling costs and...that's how AWS gets you.

Plus, local development requires half-complete emulators or a hosted database you're charged for.

No, maybe people should think twice about DynanoDB.

Re:Ask HN: Do you still use MongoDB? by danenania on Friday May 22, 2020 @01:05PM (#23274338)
This came up in a thread a few days back, but people considering it should note that Dynamo’s transactions are limited to 25 rows. That may be enough for most operations, but I definitely wouldn’t say it can handle “any transactional workload”. I ran into this limit pretty quickly when trying it out.
Re:Ask HN: Do you still use MongoDB? by gnulinux on Friday May 22, 2020 @10:08AM (#23272198)
I'm curious as well, since my company is moving from Postgres to DynamoDB.
Re:Ask HN: Do you still use MongoDB? by john-tells-all on Friday May 22, 2020 @11:12AM (#23272958)
Could you share your use case?
Re:Ask HN: Do you still use MongoDB? by aabbcc1241 on Friday May 22, 2020 @02:14PM (#23275167)
Would that be better if they had use typesceipt or jsflow for the data type ?
Re:Ask HN: Do you still use MongoDB? by marcus_holmes on Friday May 22, 2020 @11:37AM (#23273231)
I've recently adopted this practice. All new features use a JSONB (or hstore - I'm experimenting with both) field instead of a "real" one until they're bedded in and stop changing. Then I convert the field + data to a real field with a NOT NULL constraint in one easy migration.

So far so good. Being able to join on JSONB fields right in the SQL is awesome

Re:Ask HN: Do you still use MongoDB? by smoe on Friday May 22, 2020 @10:15AM (#23272279)
I never understood the appeal of the JSON to SQL columns workflow.

At least with the ORM(-ish) tools I worked with, it always felt much more straightforward to just change classes within the application code and automatically generate the respective migrations files to be run on the relational database, than having to interact as a human with json (for the app as well as for business intelligence and reporting/monitoring).

I feel I have handwritten significantly more schema and data migration code for non-sql databases and JSONB in Postgres than for relational databases in the last 10 years.

Sure once the database growths bigger, those automatically generate migrations files don't work as seamlessly anymore and can be dangerous, but no tool or database magically solves all the problems at scale.

Re:Ask HN: Do you still use MongoDB? by ken on Friday May 22, 2020 @11:09AM (#23272918)
> At least with the ORM(-ish) tools I worked with, it always felt much more straightforward to just change classes within the application code and automatically generate the respective migrations...

There's your answer, no? You've got specific tools and workflows you've designed to work with your database in a specific way. You can't just take one workflow and substitute a piece of another workflow and expect it to always work. Your tools and processes would be as useless for me as mine would be for you.

Re:Ask HN: Do you still use MongoDB? by smoe on Friday May 22, 2020 @12:40PM (#23273978)
Sure, but almost all the times (I'm not specifically referring to person in the comment I'm responding to and should have been more clear on that) people were making it fundamentally an sql vs. non-sql argument.

As in you need to switch your entire database system or make a bet on this completely new player instead of battle proven tech, because with relational databases schema migrations are hard. Among a bunch of other questionable claims.

Sure if you take the vanilla databases without their ecosystem, there is some merit to that, but I don't find it a very practical argument to ignore all the tooling and workflows that do exists and are used by people.

When MongoDB first came out, I was eager to check it out. I was using mainly Django with Postgres at the time, but had my career start on ZODB, an object-oriented non-sql database created in the late 90s. So I was hopeful that MongoDB could give me the best of both worlds. One of the reasons I backed of Mongo very quickly was the lack of tooling as soon as you have something resembling a schema or relationship and you'd want to change it.

Re:Ask HN: Do you still use MongoDB? by subhobroto on Friday May 22, 2020 @10:36AM (#23272554)
> I never understood the appeal of the JSON to SQL columns workflow.

The appeal is non-technical.

Writing good migrations, having tests around them to ensure they didn't leave the DB in an inconsistent state if a subset of them failed requires good understanding of a RDBMS and the specific product.

You'll be surprised how many engineers don't meet that criteria.

The JSON to SQL columns workflow allows any developer to offload what a RDBMS does into the client/server/bootstrap code.

At that point the DB is like a key-value store and you get to claim you are using Postgresql.

Is that what I would use if I had reliability and performance in mind?

No... but it's way cheaper (and quicker) to find devs who can do this (JSON to SQL columns workflow) than devs who can write well tested, reliable and non hacky migrations.

Often at a startup, reliability and performance have lower priority than getting some features out the door in a day.

Re:Ask HN: Do you still use MongoDB? by benglish11 on Friday May 22, 2020 @11:16AM (#23273011)
>At that point the DB is like a key-value store and you get to claim you are using Postgresql.

I know this statement is a little tongue in cheek but there is a lot of value organizationally to using Postgres as a key-value store vs MongoDb or some other flavor of no-sql. Even if you're not really getting all of the benefits of a relational db, you are still getting ACID transactions, envryption, user/access controls, backup/restore, libraries, etc. You're getting this in a tool that you are comfortable with and that you may be using in other areas where a relational model is more appropriate and thus have experience with a lot of the management aspects. Obviously if you are a mongo expert and using mongo everywhere this doesn't apply but in my experience software engineers/data engineers/DBA with postgres experience are easier to find.

Re:Ask HN: Do you still use MongoDB? by subhobroto on Friday May 22, 2020 @11:42AM (#23273281)
Hey there, thanks for reading my comments and sharing your thoughts.

> in my experience software engineers/data engineers/DBA with postgres experience are easier to find.

I need to understand what "postgres experience" means in this context. Having experience writing postgres client software using some postgres driver is a different kind of experience than installing, provisioning, monitoring and turning postgres itself.

The former is a days worth of work for any good engineer; the later can take decades and those people are really hard to find.

> you are still getting ACID transactions, envryption, user/access controls, backup/restore, libraries, etc

Sure, at a high level, making a KV-store on top of a RDBMS feels like a grand idea - hey you get ACID for free and all the RDBMS goodness while getting the flexibility of a KV-store to boot.

As they say - when something sounds too good to be true ...

One small scenario worth thinking about:

What does a KV-store on top of a RDBMS with ACID semantics even mean?

How do you handle merging objects?

Does the RDBMS even supporting merging objects inside a column?

What would happen if I have the different attributes in the same object that I then update one after the other into a JSON column on a RDBMS?

Does it fail one of the updates with an error message that data is lost?

Does it automagically merge the data? How does it even know how to handle conflicts?

Hint: No it cannot - the reason why a RDBMS can even offer ACID semantics is because RDBMS operations assume certain rules have been followed. Database Decomposition is important for a number of reliability reasons.

There are KV-stores out there that handle all these scenarios natively without the client having to worry about it (and doing a halfassed, buggy job about it because they are not DB designers). They have conflict resolution algorithms, offer CRDTs for the clients to use and engineers who know what they are doing, use them.

Using the right tool for the right job is what experienced engineers do because it not only makes their lives easier but the businesses they help run more reliable and resilient.

There is no magic.

Re:Ask HN: Do you still use MongoDB? by marcus_holmes on Friday May 22, 2020 @11:43AM (#23273286)
This is not true.

I'm using it because the cost of changing the schema for a feature that may only be experimental is too high. I started off changing the schema every time, and it just got too expensive.

Using the JSON-to-SQL workflow, I can mess around with feature design and iterate fast, and then crystallise the schema into SQL once it has stopped changing.

Writing solid migrations can end up being more complex than the feature code itself, and when features are changing fast, writing solid migrations is kinda pointless. The feature may not even make it to production.

But yeah, sure, I'm an idiot who doesn't know how to write proper SQL. rolleyes

Re:Ask HN: Do you still use MongoDB? by subhobroto on Friday May 22, 2020 @12:14PM (#23273653)
> This is not true.

Everything or certain parts of it?

> Using the JSON-to-SQL workflow, I can mess around with feature design and iterate fast, and then crystallise the schema into SQL once it has stopped changing.

Sure, you're experimenting and things are in a state of flux.

I get it. Been there done that, but not in production.

Your customers want features over reliability. This is perfectly OK at a startup - the customers already depend on a system elsewhere but that system does not meet all their needs so they are experimenting with you but if your company runs to the ground tomorrow, they still have not migrated 100% over to you, so they are "safe". If your software loses data, they probably won't even notice until they really start to move over for real and lose money (if they did not do testing for consistency).

In your position I would be honest and say data can be lost or corrupted and thats the price I am willing to pay for flexibility given the resource constraints I have.

It's too expensive to do things properly and customers don't really want that reliability so we can take some risks.

However, it would be naive to say you just designed an ACID complaint KV store by implementing some adhoc KV operations using JSON columns in a RDBMS.

I make a lot of money based off the disasters software like this creates when the original architect of such a system have "moved on" to other companies.

Data corruptions, losses, inconsistencies, meaningless key relationships, subpar performance (one place had two columns - an ID and a JSONB and were wondering why their query performance was poor, the DB locked so much and some updates never appeared to go through or "reset" the data).

There are KV-stores out there, that sell for a pretty penny, handle all KV conflict scenarios natively without the KV-store client having to worry about it (and doing a halfassed, buggy job about it because they are not DB designers and might not even know the bombs they are planting in their code. Maybe ignorance is bliss?). These systems have conflict resolution algorithms, offer CRDTs for the clients to use and engineers who know what they are doing, use them.

> The feature may not even make it to production

Feel free to do whatever you want with code that never makes it to production and affect people's livelihood.

I would argue you don't even need a DB to give you the warm fuzzy feelings and just do everything in memory.

Afterall, memory is cheap and configuring a DB correctly can get too expensive.

As an aside - if you're working at a company that regularly pushes features that do not even make it to production, there's a miscommunication issue.

Your business is bleeding money.

This is not to say overall, your business is not profitable - its just that it's bleeding money in that specific project and other more profitable ones are making up the slack.

At the minimum, the deliverable should be broken down into a POC and, when it's clear a production need absolutely exists, that POC is delivered production ready.

> Writing solid migrations can end up being more complex than the feature code itself

Sure, thats the price you pay for ACID compliance.

Nothing is free. There is no magic.

> I'm using it because the cost of changing the schema for a feature that may only be experimental is too high. I started off changing the schema every time, and it just got too expensive.

Again, you are free to do whatever you want in an experimental setup but we are talking production here.

If your proposal is you push the same design to production that you use in your experimental/POC setup, in a serious, well used and depended on production environment without anyone noticing, I would really like to know more! My contact info in the profile.

If your claim is you have figured out a way to get something for nothing - hmm.

The ROI of the businesses you help run just trended towards infinity!

Re:Ask HN: Do you still use MongoDB? by marcus_holmes on Friday May 22, 2020 @03:52PM (#23276166)
Sorry, I can't wade through that much bullshit. I got about halfway through a carefully-written refutation of everything you wrote, but you're not going to listen to me (since you didn't the first time either).

I know what I'm doing. I've been doing this for literally decades. Please stop assuming that people who don't agree with you are doing so from ignorance.

Re:Ask HN: Do you still use MongoDB? by subhobroto on Friday May 22, 2020 @04:01PM (#23276278)
> but you're not going to listen to me (since you didn't the first time either)

I listened to what you had to say the first time (which is why I responded to it) and will continue to listen to what you have to say. My contact info is on my profile.

> Please stop assuming that people who don't agree with you are doing so from ignorance

I make no such assumptions.

I shared why I think the JSON blob on a RDBMS causes more pain than it solves and I look forward to your refutation of everything I wrote.

My contact info is on my profile and I keep it there because I like to know where I am wrong.

Have a great weekend and look forward to connecting with you

Re:Ask HN: Do you still use MongoDB? by rumanator on Friday May 22, 2020 @09:27PM (#23278981)
This is perhaps the longest stream of bullshit I've ever read on HN. Congratulations on your trolling.
Re:Ask HN: Do you still use MongoDB? by smoe on Friday May 22, 2020 @12:58PM (#23274248)
Thing is, for the early stage development or prototyping, where JSON to SQL is most praised for, to be completely honest, I don't write good migrations either.

I change the application code, trigger the cli to generate the sql migration and be done with it. In 99% of cases I don't even look at the generate file, I don't write specific migration tests, etc. If migration runs without error and the application tests pass in development and staging there is a good chance it will as well in production or auto rollback saving my ass.

This works until it doesn't and you have to become much more vigilant. But at that point I much rather build upon the relative robustness and consistency of the sql I got so far, than JSON that is all over the place.

Maybe it's my tooling, but almost every time I made a JSON column in Postgres for the sake of saving time in the past, it slowed me down almost immediately after adding it.

Re:Ask HN: Do you still use MongoDB? by subhobroto on Friday May 22, 2020 @01:47PM (#23274884)
> I much rather build upon the relative robustness and consistency of the sql I got so far, than JSON that is all over the place.

Yup.

> almost every time I made a JSON column in Postgres for the sake of saving time in the past, it slowed me down almost immediately after adding it

Backs my experience fixing software from companies that had terrible data loss issues after these JSON hacks reared their ugly head.

I am not saying JSON does not belong in a DB - I have many well tested and audited code that does do that. What I am saying is I have seen things go wrong far too much, for me to trust that someone who proposes that approach to actually know what they are getting themselves into.

Plus, it's way cheaper to use a custom built KeyValDB that actually supports object semantics if one does not mean to use RDBMS semantics.

Anyways, I am being severely downvoted and cant respond until a few hours between posts so I wont be responding any longer on this thread as I have a lot of work to do the next few days and cant wait around.

See my other comments. Contact info in my profile, would love to be in touch!

Re:Ask HN: Do you still use MongoDB? by aabbcc1241 on Friday May 22, 2020 @02:32PM (#23275365)
I'm not sure what "custom built KeyValDB" means here.
Re:Ask HN: Do you still use MongoDB? by subhobroto on Friday May 22, 2020 @04:02PM (#23276298)
KeyValDB -> a pseudo adhoc Key Value store on a DataBase
Re:Ask HN: Do you still use MongoDB? by hodgesrm on Saturday May 30, 2020 @01:23PM (#23362812)
The JSON-to-columns approach is a best practice for analytic applications. ClickHouse has a feature called materialized columns that allows you to do this cheaply. You can add new columns that are computed from JSON on existing rows and materialized for new rows.
Re:Ask HN: Do you still use MongoDB? by d2161 on Friday May 22, 2020 @08:42PM (#23278721)
This. Mongodb sucked.