AWS Security ChangesHomeSearch

AWS documentdb documentation change

Service: documentdb · 2026-03-31 · Documentation low

File: documentdb/latest/developerguide/indexStats.md

Summary

Added new documentation page for the $indexStats aggregation stage in Amazon DocumentDB, including overview, parameters, MongoDB Shell example with sample data and output, and code examples in Node.js and Python

Security assessment

This change adds documentation for a database performance monitoring feature ($indexStats) that provides index usage statistics. There is no evidence of security vulnerability fixes, security incidents, or security feature documentation. The code examples include standard TLS connection parameters which are routine security best practices but not new security documentation.

Diff

diff --git a/documentdb/latest/developerguide/indexStats.md b/documentdb/latest/developerguide/indexStats.md
index 8b1378917..c32df5b1d 100644
--- a//documentdb/latest/developerguide/indexStats.md
+++ b//documentdb/latest/developerguide/indexStats.md
@@ -0,0 +1 @@
+[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#indexStats "Open PDF")
@@ -1,0 +3,124 @@
+[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html)
+
+Example (MongoDB Shell)Code examples
+
+# $indexStats
+
+The `$indexStats` aggregation stage in Amazon DocumentDB provides insight into the usage of indexes within a collection. This operator allows you to monitor the access patterns of your indexes, which can help you make informed decisions about index management and optimization.
+
+**Parameters**
+
+None
+
+## Example (MongoDB Shell)
+
+The following example demonstrates how to use the `$indexStats` operator to analyze the index usage in an Amazon DocumentDB collection.
+
+**Create sample documents**
+    
+    
+    db.grocery.insertMany([
+      { _id: 1, product: "milk", quantity: 10 },
+      { _id: 2, product: "eggs", quantity: 20 },
+      { _id: 3, product: "bread", quantity: 5 },
+      { _id: 4, product: "cheese", quantity: 15 },
+      { _id: 5, product: "apple", quantity: 8 }
+    ]);
+
+**Query example**
+    
+    
+    db.grocery.aggregate([
+      { $indexStats: {} }
+    ]);
+
+**Output**
+    
+    
+    [
+      {
+        "name": "_id_",
+        "key": {
+          "_id": 1
+        },
+        "host": "docdb-cluster-1.cluster-123456789.us-west-2.docdb.amazonaws.com",
+        "accesses": {
+          "ops": NumberLong(5),
+          "since": ISODate("2023-04-06T12:34:56.789Z")
+        }
+      },
+      {
+        "name": "product_1",
+        "key": {
+          "product": 1
+        },
+        "host": "docdb-cluster-1.cluster-123456789.us-west-2.docdb.amazonaws.com",
+        "accesses": {
+          "ops": NumberLong(10),
+          "since": ISODate("2023-04-06T12:34:56.789Z")
+        }
+      }
+    ]
+
+In this example, the `$indexStats` operator shows that the `_id_` index has been accessed 5 times, and the `product_1` index has been accessed 10 times since the last reset or server reboot.
+
+## Code examples
+
+To view a code example for using the `$indexStats` command, choose the tab for the language that you want to use:
+
+Node.js
+    
+    
+    
+    const { MongoClient } = require('mongodb');
+    
+    async function indexStats() {
+      const client = await MongoClient.connect('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false');
+      const db = client.db('test');
+      const result = await db.collection('grocery').aggregate([
+        { $indexStats: {} }
+      ]).toArray();
+      console.log(result);
+      await client.close();
+    }
+    
+    indexStats();
+
+Python
+    
+    
+    
+    from pymongo import MongoClient
+    
+    def index_stats():
+        client = MongoClient('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false')
+        db = client['test']
+        result = list(db.grocery.aggregate([
+            { '$indexStats': {} }
+        ]))
+        print(result)
+        client.close()
+    
+    index_stats()
+
+![Warning](https://d1ge0kk1l5kms0.cloudfront.net/images/G/01/webservices/console/warning.png) **Javascript is disabled or is unavailable in your browser.**
+
+To use the Amazon Web Services Documentation, Javascript must be enabled. Please refer to your browser's Help pages for instructions.
+
+[Document Conventions](/general/latest/gr/docconventions.html)
+
+$indexOfCP
+
+$isArray
+
+Did this page help you? - Yes
+
+Thanks for letting us know we're doing a good job!
+
+If you've got a moment, please tell us what we did right so we can do more of it.
+
+Did this page help you? - No
+
+Thanks for letting us know this page needs work. We're sorry we let you down.
+
+If you've got a moment, please tell us how we can make the documentation better.