What Is New in MongoDB 8.1
MongoDB 8.1 introduces a set of focused enhancements for querying, time series data, and operational resilience. This release builds on the foundation of 8.0 with key improvements for developers and operators.
| Category | Key Changes |
|---|---|
| Querying | New $median and $percentile array operators |
| Time Series | Sharding support for time series collections |
| Resilience | Performance improvements for retryable reads and writes |
| Security | OpenSSL 3.0 support and FIPS mode readiness |
| Platform | ARM64 packages for Amazon Linux 2023 and RHEL9 |
What new aggregation operators were added?
MongoDB 8.1 adds $median and $percentile operators to the aggregation framework. These operators calculate statistical measures directly within the database, eliminating the need to pull all data into application memory for analysis.
You can use them in a $group stage to compute these values across documents. This is a big win for data analytics pipelines, as it reduces both network overhead and client-side processing.
// Calculate the 50th percentile (median) and 90th percentile
db.sales.aggregate([
{
$group: {
_id: "$product",
medianPrice: { $percentile: { input: "$price", p: [ 0.5 ] } },
p90: { $percentile: { input: "$price", p: [ 0.9 ] } }
}
}
])
How is time series handling improved?
Time series collections now support sharding. This allows you to horizontally scale your time series data across a cluster, which is critical for handling massive volumes of time-stamped information from IoT sensors, financial tickers, or application metrics.
You shard a time series collection by a shard key that includes the time field. This distributes data based on time ranges, keeping recent "hot" data efficiently managed and archiving older "cold" data seamlessly.
What's better about retryable operations?
Retryable reads and writes have seen significant performance optimizations. The internal mechanics for tracking these operations are now more efficient, reducing the overhead during transient network failures or cluster elections.
In practice, this means your application's retry logic, often handled by the driver, will complete faster and with less resource consumption on the server side. This is a quality-of-life improvement that makes applications more robust without any code changes.
Are there any platform or security updates?
Yes, MongoDB 8.1 adds support for OpenSSL 3.0. This update future-proofs the database for upcoming security standards and is a prerequisite for running MongoDB in FIPS 140-2 compliant mode on supported platforms.
For deployment flexibility, official ARM64 packages are now available for Amazon Linux 2023 and Red Hat Enterprise Linux 9. This lets you run MongoDB efficiently on modern ARM-based cloud instances.
FAQ
Can I use the new $percentile operator on a non-time series collection?
Yes. The $median and $percentile operators are part of the general aggregation framework and work on any collection, not just time series.
Do I need to rewrite my time series schema to enable sharding?
No. Sharding for time series collections uses the existing metadata structure. You can enable it on existing collections, provided you choose a shard key that includes the time field.
Is OpenSSL 3.0 enabled by default in MongoDB 8.1?
Yes. MongoDB 8.1 is built and linked against OpenSSL 3.0 by default, replacing the previous OpenSSL 1.1.1 dependency.
Will my drivers automatically benefit from the retryable operations improvements?
Yes. The performance gains for retryable reads and writes are server-side improvements. Compatible drivers will automatically experience the benefits without requiring an update.
Where can I find the ARM64 packages for Amazon Linux 2023?
The packages are available through MongoDB's official repositories. You can configure your package manager to use the repo as outlined in the MongoDB documentation for installation.