Release Notes for MongoDB 5.2
On this page
Note
MongoDB 5.2 Released January 19, 2022
Patch Releases
5.2.1 - February 24, 2022
Issues fixed:
SERVER-63145 Query $densify produces incorrect results with optimizations enabled
SERVER-62981 Make SBE multi-planner's trial period termination condition independent of collection size
SERVER-62277 Performance regression from dbstats due to occupied disk space calculation
SERVER-62065 Upgrade path from 3.6 to 4.0 can leave chunk entries without history on the shards
SERVER-59754 Incorrect logging of queryHash/planCacheKey for operations that share the same $lookup shape
Aggregation
New Aggregation Operators
MongoDB 5.2 introduces the following aggregation operators:
Operator | Description |
---|---|
Returns the bottom element within a group according to the specified
sort order. | |
Returns an aggregation of the bottom n elements within a group,
according to the specified sort order. | |
Returns an aggregation of the first n elements within a group.
Distinct from the $firstN array operator. | |
Returns a specified number of elements from the beginning of an
array.
Distinct from the $firstN accumulator. | |
Returns an aggregation of the last n elements within a group.
Distinct from the $lastN array operator. | |
Returns a specified number of elements from the end of an
array.
Distinct from the $lastN accumulator. | |
Last observation carried forward. Sets values for | |
Returns an aggregation of the n maximum valued elements
within a group.
Distinct from the $maxN array operator. | |
Returns the n largest values in an array.
Distinct from the $maxN accumulator. | |
Returns an aggregation of the n minimum valued elements
within a group.
Distinct from the $minN array operator. | |
Returns the n smallest values in an array.
Distinct from the $minN accumulator. | |
Returns the top element within a group according to the specified
sort order.
Distinct from the command top . | |
Returns an aggregation of the top n elements within a group,
according to the specified sort order. | |
Sorts an array based on its elements. |
General Aggregation Improvements
$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 MongoDB 5.2, MongoDB uses the
slot-based execution query engine to execute
$group
stages when $group
is either:
The first stage in the pipeline.
Part of a series of stages executed by the slot-based engine that occurs at the beginning of the pipeline. For example, if a pipeline begins with
$match
followed by$group
, the$match
and$group
stages are executed by the slot-based engine.
In most cases, the slot-based engine provides improved performance and lower CPU and memory costs compared to the classic query engine.
Time Series Collections
Data Compression
Starting in MongoDB 5.2, time series collection data is further compressed to save database space. This compression does not affect query results, nor does it negatively affect performance.
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:
Output of the
sh.status()
method (whenverbose
is set totrue
)config.mongos
collection
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:
Prevents the start of new automatic migrations on a collection
Prevents in-flight manual migrations from committing
Excludes the collection from new balancer rounds
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
:
If true, use
ldapUserCacheRefreshInterval
.If false, use
ldapUserCacheInvalidationInterval
.
Omit Custom Data from User Output
Starting in MongoDB 5.2, you can omit customData
from the response
of the:
usersInfo
database commanddb.getUser()
methoddb.getUsers()
method
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.