I was showing my co-worker performance benchmarks of MongoDB vs SQL 2008 and while he believes MongoDB is faster, he doesn't understand how its possible. His logic, was that SQL has been around for decades, and has some of the smartest people working on it, and how can MongoDB; a relatively new kid on the block be so superior in performance? I wasn't able to really provide a solid and technical answer, and I was hoping you guys could assist.
相关问题
- MongoDB can not create unique sparse index (duplic
- Spring Data MongoDB - lazy access to some fields
- Golang mongodb aggregation
- How to convert from Timestamp to Mongo ObjectID
- MongoDB Indexing: Multiple single-field vs single
相关文章
- mongodb有没有什么办法禁止读取数据的时候进行缓存
- mongodb-aggregate聚合查询分组后如何获得多字段
- mongodb error: how do I make sure that your journa
- How to track MongoDB requests from a console appli
- MongoError: cannot infer query fields to set, path
- Pymongo $in Query Not Working
- django.core.exceptions.ImproperlyConfigured: '
- How to represent an array with mixed types
While the other answers are interesting I would add that one of the reasons MongoDB is "so fast", at least in benchmarks, is the
write concern
.You can read more about the different write concerns here but basically you can define the level of "security" you want when writing data.
The default level used to be
unacknowledged
, which means the write operation is just triggered but the driver does not check if it performed successfully. It is faster, but way less reliable.They changed it about one year ago to
acknowledged
. But I guess most of the benchmarks out there still use the 'unacknowledged` mode for better results.If you want to see the difference in term of performance, you can check this article (a bit old but it still gives an idea).
MongoDB is fast because:
MongoDB is fast because its web scale!
Its a fun video and well worth everyone watching, but it does answer your question - that most of the noSQL engines like MongoDB are not robust and not resilient to crashes and other outages. This security is what they sacrifice to gain speed.
MongoDb is faster because: 1. No transactions; 2. No relations between tables;
If you will try to do exact the same logic on SQL server, for example : 1. Do not use Select with locks ; 2. No relations between tables; It will not be so big gap in speed between SQL Server and MongoDB. Only one place definitely will be faster , write and update records, because SQL doing insert and update table in the queue and in a transaction, on MondoDB it happens asynchronously. In my projections I could not gain any big differences in speed between SQL SERVER and MongoDB, because business logic was very similar between 2 projects. Real speed gain on MongoDb you can get on Analytical projects with bid data, or on big content management engines, like news papers, online stores and etc. Again no optimization on MongoDB and good optimization on SQL server can make these databases almost equal.
I will also add that another difference is less about speed and more about conceptualization (although I believe that it might help with speed because there is less room for joining issues) is the document-based storage is very similar to object oriented mindset.
The document-based might not be perfectly ACID, but I believe MongoDB is easier to get what you want by just getting the whole document rather than messing with all the joins of a SQL DB, risking some bad joins as well.
Apologies to any SQL die-hard fans.
Mongo's not ACID compliant, so it doesn't have to deal with nearly as much "cruft" to make sure that what you try to put into the DB can come back out again later.
If you don't mind losing some functionality and possibly losing data in exchange for speed, then Mongo's good. If you absolutely need to guarantee data integrity and/or have complex join requirements, then avoid Mongo-type systems like the plague.