r/PostgreSQL • • 11h ago

Help Me! Is migrating from MongoDB to PostgreSQL worth it?

22 Upvotes

TL;DR: Running an EdTech platform with 600K+ users on MongoDB. Our data is heavily relational, and while regular API queries perform well, complex analytical queries are becoming painful to write and execute. Considering migrating to PostgreSQL and looking for advice on migration and production hosting.

Current setup:

- Node.js, MongoDB, and Mongoose.

- MongoDB Atlas (fully managed).

- 600K+ registered users and around 15K daily active users.

- An EdTech platform somewhat similar to Udemy or Coursera.

When the backend's foundations were laid, I was a junior working primarily on the frontend, so I wasn't involved in the database decision. It's been 1 year since we've been building this product.

Something that has been bothering me for a while is that we're essentially treating MongoDB like a relational database.

- Strict schemas and validations across collections.

- Heavily relational data with references between collections.

- Extensive use of aggregation pipelines and "$lookup".

- Very little reliance on MongoDB's schema flexibility.

To be fair, MongoDB has served us well. Our indexes are in place, most endpoints perform well, and we haven't faced any critical performance issues.

However, complex analytical queries for internal dashboards are a different story. Some involve joining up to 10 collections, take over 60 seconds, or occasionally time out despite optimization. Writing and maintaining these aggregation pipelines is also becoming increasingly painful.

I've experimented with MongoDB's transactions but didn't particularly enjoy the experience. I'd also like stronger database level relational integrity and better transaction management.

I feel PostgreSQL would have been a more natural fit for our data model from the beginning.

What I'd like advice on:

  1. Is migration justified? Given that MongoDB works well for most of our workloads, would migrating to PostgreSQL be worth the effort, or should I address the analytical workload separately?
  2. Migration strategy: If I proceed, how should I approach migrating a live production database at this scale? Any articles, case studies, or resources would be appreciated.
  3. PostgreSQL hosting: One thing I genuinely appreciate about MongoDB Atlas is how little I have to worry about infrastructure, backups, updates, and maintenance. What's the equivalent experience for PostgreSQL?
  4. Self-hosted vs. managed: How do you guys run PostgreSQL in production? Do you self-host it on a private EC2 instance or use something like AWS RDS, Neon, or another managed provider?

I've worked with relational databases on smaller projects, but never operated PostgreSQL in production at this scale.

I don't want to migrate just because I prefer PostgreSQL, but I also don't want to ignore what might be a fundamental architectural mismatch simply because things work today.

Would love to your thoughts and suggestions on this


r/PostgreSQL • • 20h ago

Projects Storing generated PDFs in Postgres vs object storage: where do you draw the line?

Thumbnail reddit.com
12 Upvotes

r/PostgreSQL • • 15h ago

Tools I needed a distributed DB solution, found Pigsty

0 Upvotes

(Unsure of which flair was accurate). So yeah had a project at work where I was replacing a multi-zone RDS with something on-prem. Looked at CockroachDB and Pigsty.io and after discovering breaking incompatibilities on the Cockroach side ended up choosing Pigsty.

In case anyone's interested the architecture is 5 Rocky vm's scattered across three geographically desperate offsite dcs. Two of this are in the US, the third (for quorum only really) is in the EU.

My god.. the amount of stuff the Pig folks packed into this application is astounding. Granted I do not have a prod DB in the platform just yet.. I'm seriously thinking of getting the boss to pay for some support because these folks made a fantastical distributed database application!

(posting in this sub because I will be rolling nothing but pgsql databases in this application)


r/PostgreSQL • • 23h ago

Tools be honest how many tools sit between your agent and a safe copy of prod?

Post image
0 Upvotes

so where does it break for you: test environments, agent state, or branching? and what would a single Postgres platform have to prove before you'd consolidate onto it?