Recently I have completed my MongoDB Developer Associate Certification. I also have experience using SQL Databases like MySQL and PostgreSQL. My experience in SQL is definitely a lot worse than my experience in MongoDB but I still think it should be enough for me to understand the differences between them and that I would be able to compare them in a good way. But still, when browsing this sub I see a lot of people complaining about MongoDB and saying that SQL is superior. I read these comments and try to be objective but I still find that I disagree with most of the stuff being said, even though those comments get a lot of upvotes, this makes me feel like I don't understand why it is bad or bad in certain situations. Please help me see, I want to learn!In this comment for example. I know it is kind of a meme but it still gets a lot of upvotes and I know there are a lot of people who genuinely believe that MongoDB is useless for every single use case and is basically unusable in production.Also, a lot of people say the performance of SQL databases can never be matched by databases like MongoDB but I find that not to be true. I have been googling around for a bit but can't find any nice recent performance comparisons. I can remember some benchmarks on StackOverflow that were showing that MongoDB was a few ms off compared to some SQL queries. But MongoDB offers you a lot, I find that my schemas are less complicated which also saves development cost due to reduced application complexity.There are a lot of people who say stuff like:A non-relation database? What!! Almost every schema needs relationships, what a dumb idea this can never work.This does not make any sense of course MongoDB supports relationships, it would indeed be pretty useless if it didn't. The very fact that the type "array" exists in MongoDB means that it has relations. An array. by itself basically means a one to many relationship. Also, there is support for joins ($lookup) and that kind of stuff so MongoDB clearly supports relationships. I have also seen that people say that joins in MongoDB (or $lookup) is slower than in SQL. Like I have stated above, I can't really find a good and recent performance comparison benchmark. If you do feel free to comment a link to it and I will try to update this post. But let's say theoretically that a $lookup is twice as slow as a SQL join. That would be a very large difference in a large scale project. I have had SQL projects that were around 7 to 10 tables in SQL but that could be reduced to 2 or 3 tables (collections) in MongoDB through the use of the array type. In that same schema, we sometimes had to join 5 different tables together and using MongoDB that could mostly be reduced to 0 joins ($lookup). So even if theoretically, MongoDB joins ($lookup) would be twice as slow it would have still been faster because you have to do a lot fewer joins in MongoDB compared to SQL.Also, a lot of people complain about MongoDB not supporting ACID. But MongoDB actually does support ACID through transactions.I am not an expert in any of this and I am not saying that everything I have mentioned above is correct, the opposite is true. I want to know why I am wrong please tell me and let's have a civil discussion! Sorry for being all over the place in my post. Also if I find some good comments I will try to add them to the post also if they are reasons against MongoDB (of course).
Submitted July 30, 2020 at 01:34PM by Wojtek1942
No comments:
Post a Comment