Navigation
  • Release Notes >
  • Release Notes for MongoDB 6.0 (Release Candidate)

Release Notes for MongoDB 6.0 (Release Candidate)

Important

MongoDB 5.3 binaries are currently available only as release candidates. Release candidates can be used for early testing of new features, but are not suitable for production deployments.

This version of the manual is for an upcoming release and is currently a work in progress.

This page describes changes and new features introduced in MongoDB 6.0.

MongoDB 6.0 is a |lts| Release, which means that it is supported for both MongoDB Atlas and on-premises deployments. MongoDB 6.0 includes changes introduced in MongoDB Rapid Releases 5.1, 5.2, and 5.3. This page describes changes introduced in those Rapid Releases and MongoDB 6.0.

To learn more about the differences between |lts| and Rapid releases, see MongoDB Versioning.

Aggregation

New Aggregation Stages

MongoDB 6.0 introduces the following aggregation stages:

Stage Description
$densify Creates new documents in a sequence of documents where values in a specified field are missing.
$documents Returns literal documents from input expressions.
$fill Populates null and missing field values within documents.

New Aggregation Operators

MongoDB 6.0 introduces the following aggregation operators:

Operator Description
$bottom Returns the bottom element within a group according to the specified sort order.
$bottomN Returns an aggregation of the bottom n elements within a group, according to the specified sort order.
$firstN Returns an aggregation of the first n elements within a group. Distinct from the $firstN array operator.
$firstN (array operator) Returns a specified number of elements from the beginning of an array. Distinct from the $firstN accumulator.
$lastN Returns an aggregation of the last n elements within a group. Distinct from the $lastN array operator.
$lastN (array operator) Returns a specified number of elements from the end of an array. Distinct from the $lastN accumulator.
$linearFill Fills null and missing fields in a window using :wikipedia:`linear interpolation <Linear_interpolation>` based on surrounding field values.
$locf Last observation carried forward. Sets values for null and missing fields in a window to the last non-null value for the field.
$maxN Returns an aggregation of the n maximum valued elements within a group. Distinct from the $maxN array operator.
$maxN (array operator) Returns the n largest values in an array. Distinct from the $maxN accumulator.
$minN Returns an aggregation of the n minimum valued elements within a group. Distinct from the $minN array operator.
$minN (array operator) Returns the n smallest values in an array. Distinct from the $minN accumulator.
$sortArray Sorts an array based on its elements.
$top Returns the top element within a group according to the specified sort order. Distinct from the command top.
$topN Returns an aggregation of the top n elements within a group, according to the specified sort order.
$tsIncrement Returns the incrementing ordinal from a timestamp as a long.
$tsSecond Returns the seconds from a timestamp as a long.

$lookup and $graphLookup with Sharded Collections

Starting in MongoDB 5.1, the $lookup and $graphLookup aggregation stages support sharded collections in the from parameter.

In previous versions of MongoDB, $lookup and $graphLookup only allowed for unsharded from collections.

Change Streams

Starting in MongoDB 5.1, change streams are optimized, providing more efficient resource utilization and faster execution of some aggregation pipeline stages.

Starting in MongoDB 6.0, the change stream output has a new wallTime field that contains the server date and time of the database operation.

Cluster Administration

Cluster Server Parameters

Starting in MongoDB 6.0, you can use <cluster-parameters> to modify and retrieve configuration options for all nodes in a replica set or sharded cluster. You can use setClusterParameter to modify cluster-wide options and getClusterParameter to retrieve the value of a cluster parameter.

Connection Pool Parameters

Starting in MongoDB 6.0, you can use ShardingTaskExecutorPoolMinSizeForConfigServers and ShardingTaskExecutorPoolMaxSizeForConfigServers to set the minimum and maximum sharding TaskExecutor connection pool size for configuration servers.

changeStreamOptions Cluster Parameter

Starting in MongoDB 6.0, you can use changeStreamOptions to control the retention policy of change stream pre- and post-images.

Multiple Arbiters Unsupported

Starting in MongoDB 5.3, support for multiple arbiters in a replica set is disabled by default. To enable support for multiple arbiters, start each node with the allowMultipleArbiters parameter.

Clustered Collections

Starting in MongoDB 5.3, you can create a collection with a clustered index. Collections created with a clustered index are called clustered collections.

To learn about the benefits compared to a normal collection, see Clustered Collections.

Indexes

Starting in MongoDB 5.1, you can use the collMod database command to add the expireAfterSeconds option to an existing single-field non-TTL index.

Starting in MongoDB 6.0, you can use the prepareUnique and unique options for the collMod command to convert an existing standard index to a unique index.

Installation

SELinux Policies

Starting in MongoDB 5.1, there is a new SE Linux Policy for:

running on Red Hat Linux. The SELinux policy is for use with default installations using rpm installer packages.

Replica Sets

Multiple Arbiters Unsupported

Starting in MongoDB 5.3, support for multiple arbiters in a replica set is disabled by default. To enable support for multiple arbiters, start each node with the allowMultipleArbiters parameter.

initialSyncMethod Parameter

Starting in MongoDB 5.2, the initialSyncMethod determines whether initial sync is a logical initial sync or a file copy based initial sync.

initialSyncMethod is only available in MongoDB Enterprise Server.

Specify Secondary Oplog Batch Delay

Starting in MongoDB 6.0, you can use the oplogBatchDelayMillis server parameter to specify a delay for writes of oplog batches on secondaries. Adding a short oplog batch delay can reduce IOPS on secondaries, but adds latency for writes with write concern "majority".

For more information, see oplogBatchDelayMillis.

Security

Audit Log Encryption

Starting in MongoDB 6.0 Enterprise, you can encrypt the MongoDB audit log.

To configure the audit log, see Use KMIP Server to Manage Keys for Encrypting the MongoDB Audit Log.

Sharding

Default Chunk Size Increased from 64 MB to 128 MB

Starting in MongoDB 5.2, the default chunk size is 128 megabytes. In earlier versions of MongoDB, the default chunk size is 64 megabytes.

enableSharding No Longer Required

Starting in MongoDB 6.0, the enableSharding command is no longer required to shard a collection.

Slot-Based Query Execution Engine

Starting in MongoDB 5.1, MongoDB uses a new query execution engine for eligible queries, called the slot-based query execution engine. If the slot-based query execution engine is used, new fields are included in the query explain plan output.

  • The new query execution engine is used if possible.
  • If the new query execution engine is used, new fields are included in the query explain plan output.

|sbe-title| Can Execute $group and $lookup Stages

Starting in version 6.0, MongoDB uses the |sbe| to execute eligible $group and $lookup stages when certain conditions are met.

For more information, see |sbe-title| Pipeline Optimizations.

Set |sbe-title| Plan Cache Size

You can set the size of the plan cache for the new query engine with the planCacheSize parameter.

Increasing the plan cache size adds more cached query shapes for the query planner. This can improve query performance, but increases memory usage.

Stable API

The following sections describe additions to the Stable API introduced in MongoDB 6.0.

To see the full list of database commands available in the Stable API, see Stable API Changelog.

Database Commands

Starting in MongoDB 6.0, the following database commands are supported in the Stable API:

Command Description Stable API Version
count Counts the number of documents in a collection or a view. (Also available in the Stable API for 5.0-series deployments starting in MongoDB 5.0.9.) V1

Aggregation Stages and Operators

Starting in MongoDB 6.0, the following aggregation stages and operators are supported in the Stable API:

Stage or Operator Description Stable API Version
$bottom Returns the bottom element within a group, according to the specified sort order. V1
$bottomN Returns an aggregation of the bottom n elements within a group, according to the specified sort order. V1
$dateAdd Increments a Date object by a specified number of time units. V1
$dateDiff Returns the difference between two dates. V1
$dateSubtract Decrements a Date object by a specified number of time units. V1
$dateTrunc Truncates a date. V1
$densify Creates new documents in a sequence of documents where certain values in a field are missing. V1
$firstN (aggregation accumulator) Returns an aggregation of the first n elements within a group. V1
$firstN (array operator) Returns a specified number of elements from the beginning of an array. V1
$getField Returns the value of a specified field from a document. V1
$lastN (aggregation accumulator) Returns an aggregation of the last n elements within a group. V1
$lastN (array operator) Returns a specified number of elements from the end of an array. V1
$locf Last observation carried forward. Sets values for null and missing fields in a window to the last non-null value for the field. V1
$maxN (aggregation accumulator) Returns an aggregation of the maximum value n elements within a group. V1
$maxN (array operator) Returns the n largest values in an array. V1
$minN (aggregation accumulator) Returns an aggregation of the minimum value n elements within a group. V1
$minN (array operator) Returns the n smallest values in an array. V1
$setField Adds, updates, or removes a specified field in a document. V1
$setWindowFields Performs operations on a specified span of documents in a collection, known as a window, and returns the results based on the chosen window operator. V1
$sortArray Sorts an array based on its elements. V1
$top Returns the top element within a group according to the specified sort order. V1
$topN Returns an aggregation of the top n elements within a group, according to the specified sort order. V1
$tsIncrement Returns the incrementing ordinal from a timestamp as a long. V1
$tsSecond Returns the seconds from a timestamp as a long. V1

Window Operators

Starting in MongoDB 6.0, the following window operators are supported in the Stable API:

Window Operator Description Stable API Version
$addToSet Returns an array of all unique values that results from applying an expression to each document. V1
$avg Returns the average for the specified expression. Ignores non-numeric values. V1
$count Returns the number of documents in the group or window. V1
$covariancePop Returns the population covariance of two numeric expressions. V1
$covarianceSamp Returns the sample covariance of two numeric expressions. V1
$denseRank Returns the document position (known as the rank) relative to other documents in the $setWindowFields stage partition. There are no gaps in the ranks. Ties receive the same rank. V1
$derivative Returns the average rate of change within the specified window. V1
$documentNumber Returns the position of a document (known as the document number) in the $setWindowFields stage partition. Ties result in different adjacent document numbers. V1
$expMovingAvg Returns the exponential moving average for the numeric expression. V1
$first Returns the value that results from applying an expression to the first document in a group or window. V1
$integral Returns the approximation of the area under a curve. V1
$last Returns the value that results from applying an expression to the last document in a group or window. V1
$locf Last observation carried forward. Sets values for null and missing fields in a window to the last non-null value for the field. V1
$max Returns the maximum value that results from applying an expression to each document. V1
$min Returns the minimum value that results from applying an expression to each document. V1
$push Returns an array of values that result from applying an expression to each document. V1
$rank Returns the document position (known as the rank) relative to other documents in the $setWindowFields stage partition. V1
$shift Returns the value from an expression applied to a document in a specified position relative to the current document in the $setWindowFields stage partition. V1
$stdDevPop Returns the population standard deviation that results from applying a numeric expression to each document. V1
$stdDevSamp Returns the sample standard deviation that results from applying a numeric expression to each document. V1
$sum Returns the sum that results from applying a numeric expression to each document. V1

Time Series Collections

The following sections describe improvements and new features for time series collections.

Sharded Time Series Collections

MongoDB 5.1 provides support for sharded time series collections.

See:

Updates and Deletes

Starting in MongoDB 5.1, time series collections support update and delete operations with limitations.

Time Series Column Compression

Starting in MongoDB 5.2, time series collections use column compression. Column compression adds a number of innovations that work together to significantly improve practical compression, reduce your data’s overall storage on disk, and improve read performance.

Starting in MongoDB 6.0, arrays are also compressed as part of the time series column compression.

Support for $geoNear

Starting in MongoDB 5.3, you can use the $geoNear pipeline operator on any field in a time series collection.

Additional Secondary Index Types

You can add additional secondary index types to time series collections, including 2dsphere and 2d indexes.

For all additional indexes and other improvements, see Time Series Secondary Indexes in MongoDB 6.0.

Sort Operations Use Secondary Indexes

Sort operations on time series collections can use indexes to improve performance. For more information and an example, see Use Secondary Indexes to Improve Sort Performance.

General Improvements

Capped Collections Improvements

Starting in MongoDB 6.0, you can change a capped collection’s maximum size, either in bytes or in number of documents, using the collMod command. See Resize a Capped Collection for more details.

numOrphanDocs Field Added to collStats Command

Starting in MongoDB 6.0, the collStats output includes the collStats.numOrphanDocs field that shows the number of orphaned documents in the collection.

Change Streams with Document Pre- and Post-Images

Starting in MongoDB 6.0, you can use change streams to output the version of a document before and after changes (the document pre- and post-images). For examples, see Change Streams with Document Pre- and Post-Images.

Change Stream Expanded Events

Starting in MongoDB 6.0, change streams can be configured to show additional change events for DDL operations, like index creation and collection drop.

For more information, see Expanded Events.

Exclude Embedded Fields in serverStatus Output

Starting in MongoDB 6.0 (and 5.0.9, 4.4.15), you can exclude embedded fields from the serverStatus output.

Connections

Starting in MongoDB 6.0, the Mongo() connection object has the following new methods:

Changes Affecting Compatibility

Some changes can affect compatibility and may require user actions. For a detailed list of compatibility changes, see Compatibility Changes in MongoDB 6.0 (Release Candidate).

Upgrade Procedures

Important

Feature Compatibility Version

To upgrade to MongoDB 6.0 from a 5.0 deployment, the 5.0 deployment must have featureCompatibilityVersion set to 5.0. To check the version:

db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )

To upgrade to MongoDB 6.0, refer to the upgrade instructions specific to your MongoDB deployment:

  • <6.0-upgrade-standalone>
  • <6.0-upgrade-replica-set>
  • <6.0-upgrade-sharded-cluster>

If you need guidance on upgrading to 6.0, MongoDB professional services offer major version upgrade support to help ensure a smooth transition without interruption to your MongoDB application. To learn more, see MongoDB Consulting.

Report an Issue

To report an issue, see https://github.com/mongodb/mongo/wiki/Submit-Bug-Reports for instructions on how to file a JIRA ticket for the MongoDB server or one of the related projects.

Search Results
    Was this page helpful?