What Is New in MongoDB 2.7
MongoDB 2.7 is a significant release packed with enhancements to the aggregation framework, security, and overall database operations. Here's a quick summary of the key changes.
| Category | Key Changes |
|---|---|
| New Features | Aggregation Pipeline enhancements ($out, $lookup), Document Validation, SCRAM-SHA-256 Authentication |
| Improvements | WiredTiger storage engine performance, MMAPv1 improvements, explain plan output |
| Security | SSL Certificate Validation, x.509 Authentication, LDAP Authorization |
| Deprecated | MMAPv1 as default storage engine, group command, eval |
What are the major aggregation framework upgrades?
The aggregation pipeline got a massive boost in 2.7. The new $out operator lets you write the results of a pipeline directly into a new collection, which is perfect for creating materialized views or archiving data. This is way more flexible than the old group command.
We also saw the introduction of the $lookup operator for performing left outer joins between two collections. This was a game-changer for handling relational data patterns directly in MongoDB, reducing the need for application-side joins.
How did document validation change the game?
Document validation finally gave us a way to enforce schema rules at the database level. You can specify validation rules when creating a collection using the validator option, which defines allowed structures and data types for documents.
In practice, this meant we could prevent bad data from entering the system at the source, making application code more robust. You could choose to just log warnings or outright reject documents that didn't conform to the specified rules.
What security enhancements were introduced?
Security got a major overhaul with support for SCRAM-SHA-256 authentication, a stronger mechanism than the previous SCRAM-SHA-1. This was a crucial step forward for securing client-server communication.
On the encryption front, SSL certificate validation became more strict by default, ensuring secure connections. The release also laid the groundwork for more advanced features like x.509 certificate authentication and LDAP authorization for enterprise deployments.
What performance improvements stood out?
WiredTiger became the default storage engine, bringing native compression and document-level locking. This was a huge win for performance and efficiency on modern hardware compared to the older MMAPv1 engine.
The explain command also saw improvements, providing much more detailed and useful output for analyzing query performance. This made it significantly easier for developers to identify and fix slow queries.
FAQ
Can I use $lookup to join more than two collections?
No, the initial implementation of $lookup in 2.7 only supports a single left outer join between two collections. For more complex joins involving multiple collections, you would need to chain multiple $lookup stages in your aggregation pipeline.
Does document validation affect existing documents?
No, validation rules are only applied to inserts and updates that occur after the validator is set. Existing documents in the collection are not checked unless they are modified.
Is SCRAM-SHA-256 backwards compatible?
For a smooth transition, MongoDB 2.7 supports both SCRAM-SHA-1 and SCRAM-SHA-256 authentication mechanisms. However, upgrading clients to use the newer, more secure method is strongly recommended.
Why was WiredTiger made the default?
WiredTiger offered superior performance with document-level concurrency control and built-in compression, providing better throughput and more efficient storage utilization than the MMAPv1 engine.
What replaces the deprecated group command?
The aggregation framework, specifically the $group stage, is the intended replacement. It's far more powerful and flexible, supporting complex grouping operations and integration with other pipeline stages.