When should I use MongoDB vs PostgreSQL for a new project?
Starting a new project and trying to pick a database. Everyone seems to either love or hate MongoDB. My app will have users, posts, comments - pretty standard social-app stuff. Is there actually a technical reason to choose one over the other or is it just preference?
1 Answer
Best -->
Backend dev with 10+ years of experience here. Both are good databases, but for different reasons.
For your standard social app: PostgreSQL is the better choice.
Here's why:
Your data is relational:
- Users have posts
- Posts have comments
- Comments belong to users
- Users follow other users
- 2010s: NoSQL was trendy
- Truly schemaless data needs
- Rapid prototyping (no migrations needed)
- Data that doesn't fit neatly into tables
- Extreme horizontal scaling needs
- No JOINs = multiple queries or denormalization
- Data consistency is harder
- You end up recreating relational features manually
- Schema changes are actually harder at scale (you can't enforce them)
- Duplicate data everywhere
- Complex application-level joins
- Data inconsistencies
- Eventually migrating to Postgres anyway
- Content management with flexible schemas
- Logging/analytics data
- Caching layer
- Truly document-oriented data
- Specific gaming/IoT use cases
- 95% of web applications
- Relational data (users, posts, orders, etc.)
- Complex queries needed
- ACID compliance matters
- JSON support still needed (Postgres has JSONB)
This is textbook relational data. PostgreSQL is designed exactly for this.
Why MongoDB became popular (and when it makes sense):
Why MongoDB can hurt you:
Real talk from experience:
I've seen so many startups choose MongoDB because it's "modern" and then spend years fighting it:
When MongoDB actually makes sense:
When Postgres makes sense:
My recommendation:
Start with PostgreSQL. It handles JSON when you need flexibility, gives you proper relations for structured data, and won't fight you as you scale.
MongoDB is great for what it's designed for. A social app isn't that.
Asked By
AI Suggested
Topic
Browse more questions in this topic
Hot Questions
-
How do I validate a startup idea before quitting m...
908 views -
Why is my WiFi so slow even though I have fast int...
904 views -
Is Duolingo actually effective for learning a lang...
900 views -
Side hustle vs full business - when do you make th...
796 views -
Are online degrees taken seriously by employers?
790 views
Top Users
-
1
1,000
-
2
320
-
3
282
-
4
270
-
5
255
Recent Blogs
View AllRecent Activity
-
Stephanie White answered
What is the hardest language for English... -
Brittany Thomas asked
Remote team management - how do you know... -
Christopher Miller answered
Which Linux distribution would you recom... -
Ashley Davis answered
Best way to track monthly expenses witho... -
David Jones asked
What's the best programming language to ...