DEV Community

Discussion on: Comparing MongoDB & MySQL

Collapse
 
bgadrian profile image
Adrian B.G.

Yes, Mongodb has a join since 3.2, but do not take it lightly, it's not a 1:1 replacement. The feature is part of the aggregation framework, you will not want to aggregate data for each user request, it's not meant to be used like this because it needs more resources to return the result.
To avoid these you usually make subdocuments and keep the data in a single big object so you do not require a join.
If your data can be easily put in an excel like table then you shortly use a relationship DB.

Collapse
 
xowap profile image
Rémy 🤖

My motto is: if you can put it in a table then put it in PostgreSQL. If you can't, then put it in PostgreSQL anyways, it has indexed JSON fields after all.

Thread Thread
 
hassan14_pk profile image
Hassan

I guess my line would be to 'if you can put it in NoSQL then do that' and I come from SQL and Oracle.

Collapse
 
xowap profile image
Rémy 🤖

Interesting to know that $lookup is heavy though, I did use it without noticing performance issues but that's still something to consider.

Thread Thread
 
bgadrian profile image
Adrian B.G.

The lookup alone I don't think adds roo much, but usually you need other ops.
And try the test on a large db, eventually with sharding then you'll see the out of memory issue 😀

Thread Thread
 
xowap profile image
Rémy 🤖

large remains to be defined but yup I see the idea

Collapse
 
gpasq profile image
Greg Pasquariello

"To avoid these you usually make subdocuments and keep the data in a single big object so you do not require a join. "

That's a sure-fire way to make your database unusable down the road.