Why MongoDB Beats Relational Databases—and Where It Falls Short
This article compares MongoDB to traditional relational databases, highlighting advantages such as eventual consistency, document storage, built‑in GridFS and sharding, rich third‑party support, and performance, while also discussing drawbacks like lack of transactions, high disk usage, and limited maintenance tools.
Advantages of MongoDB over Relational Databases
1. Weak Consistency (Eventual Consistency) Improves Access Speed
In relational databases a COUNT operation locks the dataset to guarantee an exact current value, which is essential for scenarios like ATM balance checks but adds latency for constantly changing data. MongoDB favors an approximate count that can be returned much faster.
MongoDB can still lock the database under heavy load. To avoid this, the article recommends querying the record first so the document is loaded into memory, then updating it quickly. In a master‑slave setup, the slave can be started with the -pretouch flag to achieve the same effect.
Run multiple mongod processes and split the database according to access patterns.
2. Document‑Oriented Storage Simplifies Data Retrieval
Hierarchical data stored as flat tables is difficult to query and retrieve. MongoDB’s document model stores data in a natural, nested format, making both queries and data access far easier.
3. Built‑in GridFS Supports Large Data Sets
GridFS is a distributed file system integrated into MongoDB that enables efficient storage and range queries for massive data collections.
4. Built‑in Sharding
MongoDB provides an automatic range‑based sharding mechanism. A collection can be split into multiple chunks and distributed across shards. Combined with replica sets, sharding offers fail‑over, load balancing, and transparent routing of queries, aggregations, and MapReduce operations. The design can support up to roughly 20 petabytes.
5. Rich Third‑Party Support
Unlike many community‑only NoSQL projects, MongoDB is backed by the commercial company 10gen (now MongoDB Inc.) which offers training and support. An active community quickly adds driver support for frameworks such as Django and Ruby on Rails, and many large companies use MongoDB in production.
6. Superior Performance
For workloads with millions of documents and tens of gigabytes of data, indexed ID queries are as fast as MySQL, while non‑indexed field queries are consistently faster. Write performance is also strong; inserting millions of records is noticeably quicker than with CouchDB, and MongoDB does not become a CPU bottleneck.
Disadvantages of MongoDB Compared to Relational Databases
1. No Transaction Support
MongoDB does not provide ACID‑compliant multi‑document transactions, making it unsuitable for systems that require strict transactional guarantees, such as banking applications.
2. High Disk Space Consumption
Several factors cause MongoDB to use more storage than relational databases:
Preallocation: MongoDB allocates large chunks of disk space (64 MB, 128 MB, 256 MB, up to 2 GB per file) to reduce fragmentation, causing rapid growth of data files.
Field‑name overhead: Each field’s key is stored in BSON format. Long field names increase overhead, especially for numeric values. Shortening field names reduces size but trades readability for space.
Deleted records are not immediately reclaimed; they are marked as deleted and can be reused later, leaving apparent wasted space.
Running db.repairDatabase() reclaims space but can be slow.
3. Immature Maintenance Tools
MongoDB lacks the mature, feature‑rich administration utilities that MySQL provides, which can be a concern for developers and IT operations teams.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ITPUB
Official ITPUB account sharing technical insights, community news, and exciting events.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
