For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
See how MongoDB 9.0 delivers up to 2x higher throughput.
MongoDB Branding Shape
Register now >
Docs Menu

Check if a Collection is Capped

To check if a collection is capped, use the isCapped() method.

Generally, TTL (Time To Live) indexes offer better performance and more flexibility than capped collections. TTL indexes expire and remove data from normal collections based on the value of a date-typed field and a TTL value for the index.

Capped collections serialize write operations and therefore have worse concurrent insert, update, and delete performance than non-capped collections. Before you create a capped collection, consider if you can use a TTL index instead.

Create a non-capped collection and a capped collection:

db.createCollection("nonCappedCollection1")
db.createCollection("cappedCollection1", { capped: true, size: 100000 } )

To check if the collections are capped, use the isCapped() method:

db.nonCappedCollection1.isCapped()
db.cappedCollection1.isCapped()
false
true