DEV Community

Amanpreet Singh
Amanpreet Singh

Posted on • Originally published at blog.amanpreet.dev on

MongoDB 8.0: An Overview of the Latest Features and Upgrades

MongoDB 8.0: An Overview of the Latest Features and Upgrades

Introduction

The recent release of MongoDB 8.0 continues its tradition of innovation, introducing enhancements that promise to revolutionize how developers interact with data. Whether you're a seasoned MongoDB user or exploring it for the first time, this latest version offers exciting opportunities to elevate your development.

MongoDB is used across various industries, from large-scale e-commerce platforms and stream processing to transactional systems and complex Internet of Things (IoT) networks.

Whats new in MongoDB 8.0?

Performance Updates

The most popular document database is now faster than ever,

With 36% quicker reads ,

59% higher throughput for updates ,

200% faster time-series aggregations ,

and up to 50 times faster resharding.

Image depicting the performance improvements of MongoDB 8.0. In order going down the image, YCSB Bulk Load is 56% faster, YCSB 100% Read is 36% faster, TCSV 95/5 is 32% faster, Linkbench is 24% faster, and TSBS is 60% faster.

Logging

  • You can configure the DB Profiler to log slow operations based on the time that MongoDB takes to process an operation, rather than the total latency of the operation. This allows for more accurate logging of slow queries, as it focuses specifically on the time MongoDB spends processing them.

  • Slow query logs feature a metric called queues.execution.totalTimeQueuedMicros. This metric helps determine if an operation is slow due to the time it takes to complete or the time it spends waiting to start.

  • Query analysis tools like the Query Profiler, Performance Advisor, and Search Query Telemetry report slow operations based on workingMillis rather than durationMillis. This shift offers a more accurate view of problematic queries.

Aggregation

  • You can use $convert operator to convert string values to binData values and vice versa.

  • New helper expression, $toUUID which provides simplified conversions of strings to UUID values.

  • Behavior of $rank and $denseRank: In MongoDB 8.0, null and missing field values in $denseRank and $rank for sortBy operations are treated the same when calculating rankings, thus making the behavior of $denseRank and $rank consistent with $sort.

Security

  • Starting in MongoDB 8.0, Queryable Encryption supports the range queries on encrypted fields. You can use $lt, $gt, $lte, and $gte operators on encrypted fields.

  • Open Cybersecurity Schema Framework : In MongoDB 8.0, you can specify the OCSF schema for audit log messages.

{
     "activity_id" : <int>,
     "category_uid" : <int>,
     "class_uid" : <int>,
     "time" : <int>,
     "severity_id" : <int>,
     "type_uid" : <int>,
     "metadata" : <document>
     "actor" : {
        "user" : {
           "type_id" : <int>,
           "name" : <string>,
           "groups" : <array of documents>
        }
     }
  }
Enter fullscreen mode Exit fullscreen mode
  • Ingress Queue : MongoDb 8.0 introduces a new queue for ingress admission control. Operations waiting to enter the database from the network are placed in the ingress queue.

By default, this queue is unrestricted, allowing all operations to proceed without any queuing. However, by setting a maximum limit for the queue, you can manage operations at this stage, queuing them if the number of concurrent operations reaches the specified limit.

Replication & Sharding

  • Majority Write Concern : In previous releases, write operations that use the majority write concerns would wait and return an acknowledgement after the majority of replicate set members applied the change.

    Starting in MongoDB 8.0, these operations return an acknowledgement when the majority of replica set members have written the oplog entry for the change.

  • Moving a Collection : Starting in MongoDB 8.0, you can unshard collections and move unsharded collections between shards on sharded clusters.

  • Use of $lookup stage in Transactions : Starting with MongoDB 8.0, you can use the $lookup stage within a transaction when targeting a sharded collection.

  • Store Application Data on Config Shards : Starting in MongoDB 8.0, you can configure a config server to store application data in addition to the usual sharded cluster metadata. The config server is then known as a config shard.

General Changes

  • Bulk Write command: The existing bulkWrite() method only allows to modification of one collection in one request but from MongoDB 8.0, you can use the new bulkWrite command to perform many insert, update and delete operations on multiple collections in one request.

  • New Query Shape and Query Settings

  • Read Concern on Capped Collections

  • Parameter Filtering

  • Shutdown Performance

  • Sort Support for updateOne

  • Query Planner Optimization Time : The method explain() returns information on query planner optimization time. The queryPlanner.optimizationTimeMillis status shows the time in milliseconds that the query planner spent on optimizations.

Upgrading to MongoDB 8.0

To upgrade to MongoDB 8.0 from a 7.x deployment, the 7.x deployment must have featureCompatibilityVersion set to 7.x.

To check the version use the below command

db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
Enter fullscreen mode Exit fullscreen mode

To download MongoDB 8.0, go to the MongoDB Download Center.

If you're interested in the latest features of MongoDB 7.0 instead of the newest version, you can find the information here.

Conclusion

MongoDB 8.0 has certainly raised the bar. With a full set of new features, security improvements, and other performance enhancements, MongoDB 8.0 is the perfect choice for organizations looking to take their development to the next level.

I hope you have learned something new, as I did. If so, kindly like and share the article, and follow me to read more exciting articles.

References

MongoDB Docs

Release Notes for MongoDB

Top comments (0)