DocumentDB 0.113: Index-Only Access for $group Operations
DocumentDB, the open-source PostgreSQL extension that emulates the MongoDB API, has reached version 0.113. This release introduces a significant performance enhancement for aggregation queries: the ability to use a covering index for $group operations. This builds directly on previous work to optimize how MongoDB queries interact with PostgreSQL's underlying data structures, moving beyond simple syntax parsing to true execution path translation.
Previously, developers working with MongoDB aggregations, particularly those involving $group and summation, might have relied on hinted indexes to encourage the database to read directly from index entries rather than fetching entire documents. This technique aimed to reduce I/O by avoiding document retrieval when all necessary fields were available within the index itself. DocumentDB 0.113 now natively supports this index-only access path within its PostgreSQL execution engine. This means that for specific $group queries, DocumentDB can now perform the aggregation directly from index data, bypassing the need to read the full documents from disk. This is a crucial step in making MongoDB workloads run more efficiently on PostgreSQL.
Microsoft, a primary contributor to DocumentDB, has been instrumental in this development. Their efforts are informed by feedback from enterprise customers using Azure DocumentDB, indicating a clear demand for such performance optimizations in production environments. The core value proposition of DocumentDB lies in its ability to translate MongoDB operators into native PostgreSQL access paths and executor operations, rather than simply filtering documents. This approach ensures that applications can leverage the robustness and scalability of PostgreSQL while maintaining compatibility with the MongoDB API.
The Mechanics of Covering Indexes for $group
A covering index, in the context of database operations, is an index that contains all the fields required to satisfy a query. For a $group aggregation, this typically means an index that includes the fields used in the $group stage (the grouping keys) and any fields used in projection or summation within the $group stage. When a query can be satisfied entirely by reading from such an index, it's known as an index-only scan.
Before DocumentDB 0.113, a MongoDB query that could benefit from a covering index might still require DocumentDB to fetch the full documents from PostgreSQL. The PostgreSQL execution engine, while powerful, would need to perform a table access after retrieving index entries if the index wasn't sufficient on its own. With the addition of the index-only access path for $group, DocumentDB 0.113 allows the PostgreSQL executor to perform the aggregation directly from the index data. This is analogous to how MongoDB itself might optimize such queries.
Consider a scenario where you are aggregating sales data to find the total revenue per product. Your aggregation might look like this:
db.sales.aggregate([
{
$group: {
_id: "$productId",
totalRevenue: { $sum: "$amount" }
}
}
])
If you have a covering index on { productId: 1, amount: 1 }, DocumentDB 0.113 can now use this index to compute the totalRevenue for each productId without reading the individual sales documents. This dramatically reduces the amount of data that needs to be processed, leading to faster query execution times and lower resource consumption.

Broader Implications for MongoDB on PostgreSQL
The introduction of index-only access for $group in DocumentDB 0.113 is a significant step in its evolution. It demonstrates a commitment to not just emulating MongoDB syntax, but to deeply integrating MongoDB operations with PostgreSQL's performance capabilities. This approach makes DocumentDB a compelling option for organizations looking to migrate MongoDB workloads to a more open and potentially cost-effective database platform without sacrificing performance for critical aggregation tasks.
This development also highlights the ongoing convergence between NoSQL and SQL database technologies. By translating NoSQL operations into native SQL access paths, DocumentDB is effectively bridging the gap, allowing developers to leverage familiar MongoDB tools and APIs while benefiting from the mature ecosystem and performance optimizations of PostgreSQL. The fact that this feature is driven by enterprise feedback underscores its practical importance in real-world deployments.
Looking ahead, this enhancement sets the stage for further optimizations. The principle of index-only access is a foundational technique for database performance. Its successful implementation for $group suggests that other complex MongoDB operations could similarly be mapped to efficient PostgreSQL execution strategies. This continuous improvement benefits anyone running MongoDB applications on DocumentDB, offering a path to enhanced performance and scalability.
DocumentDB 0.116: Extending Loose Index Scans for $group
Building on the foundation laid in version 0.113, DocumentDB version 0.116, released on August 20, 2026, further refines the handling of $group queries. This release extends the principle of loose index scans, previously applied to $first and $last per group queries, to a broader category of $group operations. Specifically, it targets $group queries that aim to return a single row for each distinct grouping key.
This new capability in DocumentDB 0.116 combines the loose index scan with the index-only access path that was introduced in 0.113. A loose index scan allows the database to skip over index entries that belong to the same group once it has processed one entry for that group. This is particularly effective for queries that need to find the first or last document within each group, or in this case, to aggregate values per distinct group efficiently.
The implication here is that DocumentDB continues to mature in its ability to translate complex MongoDB aggregation patterns into highly optimized PostgreSQL operations. By leveraging PostgreSQL's DISTINCT ON capabilities, which are conceptually similar to MongoDB's $group with specific optimizations, DocumentDB can achieve performance gains. This approach ensures that the MongoDB API is not just a thin layer but is deeply integrated with the underlying relational database's power.
Microsoft's continued contribution to DocumentDB, driven by enterprise customer needs, suggests a strong roadmap for enhancing its performance and feature set. For developers and organizations migrating or running MongoDB applications on PostgreSQL, these ongoing improvements are critical. They indicate that DocumentDB is evolving into a robust, performant, and feature-complete alternative to native MongoDB deployments.
