Docs HomeMongoDB Manual

Release Notes for MongoDB 5.2

Important

MongoDB 5.2 is a rapid release and is only supported for MongoDB Atlas. MongoDB 5.2 is not supported for use on-premises. For more information, see MongoDB Versioning.

Patch Releases

5.2.1 - February 24, 2022

Issues fixed:

5.2.0 - Jan 19, 2022

The rest of this page provides the 5.2.0 release notes:

Aggregation

New Aggregation Operators

MongoDB 5.2 introduces the following aggregation operators:

OperatorDescription
$bottomReturns the bottom element within a group according to the specified sort order.
$bottomNReturns an aggregation of the bottom n elements within a group, according to the specified sort order.
$firstNReturns 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.
$lastNReturns 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.
$locfLast observation carried forward. Sets values for null and missing fields in a window to the last non-null value for the field.
$maxNReturns 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.
$minNReturns 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.
$topReturns the top element within a group according to the specified sort order. Distinct from the command top.
$topNReturns an aggregation of the top n elements within a group, according to the specified sort order.
$sortArraySorts an array based on its elements.

General Aggregation Improvements

$filter Operator's limit Field

Starting in MongoDB 5.2, the $filter operator includes the optional limit field. The limit field restricts the number of matching array elements that the $filter operator returns.

$convert Supports Timestamp Conversion to Date

Starting in MongoDB 5.2, you can convert timestamps to dates using the $convert operator. The $toDate operator can also convert timestamps.

Improved Precision for Operator Counters

Starting in MongoDB 5.2 and 5.0.6, aggregation operator metrics are more precise: internal processing does not inflate the counters.

Slot-Based Query Execution Engine Can Execute $group Stages

Starting in version 5.2, MongoDB uses the slot-based execution query engine to execute $group stages if either:

  • $group is the first stage in the pipeline.
  • All preceding stages in the pipeline can also be executed by the slot-based execution engine.

For more information, see $group Optimization.

Time Series Collections

Data 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.

See time series collection behavior.

Sharding Administration Commands

Starting in MongoDB 5.2, you can run sharding administration commands (such as moveChunk) on the system.buckets collection.

Sharding

Starting in MongoDB 5.2, the time that a mongos was started is included in the:

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.

Prevent Migrations on a Sharded Collection with setAllowMigrations

Starting in MongoDB 5.2, the setAllowMigrations command:

Limit Wait Time For Critical Section

Starting in MongoDB 5.2 (and 5.0.4, 5.1.0)

The metadataRefreshInTransactionMaxWaitBehindCritSecMS parameter limits the time a shard waits for a critical section within a transaction.

General Improvements

Configure Refresh Interval for Cached LDAP User Information

Starting in MongoDB 5.2, you can use the following new server parameters to configure the refresh interval for cached LDAP user information:

Starting in MongoDB 5.2, the update interval for cached user information retrieved from an LDAP server depends on ldapShouldRefreshUserCacheEntries:

Omit Custom Data from User Output

Starting in MongoDB 5.2, you can omit customData from the response of the:

To omit custom data from command output, specify the showCustomData: false option.

Replica Sets

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.

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.