What is the MongoDB Capped Collection maximum allowable size?

MongoDB capped collections can be set to any size you specify using the size parameter. There is no fixed maximum limit − the size is constrained only by your available disk space and system resources.

Syntax

db.createCollection('collectionName', {
    capped: true,
    size: sizeInBytes
});

Example

Create a capped collection with a large size limit ?

db.createCollection('cappedCollectionMaximumSize', {
    capped: true,
    size: 1948475757574646
});
{ "ok" : 1 }

Verify Collection Properties

Check the collection statistics to confirm the size setting ?

db.cappedCollectionMaximumSize.stats();
{
    "ns" : "test.cappedCollectionMaximumSize",
    "size" : 0,
    "count" : 0,
    "storageSize" : 4096,
    "capped" : true,
    "max" : NumberLong("9223372036854775807"),
    "maxSize" : NumberLong("1948475757574646"),
    "ok" : 1
}

Key Points

  • The size parameter accepts values in bytes.
  • MongoDB will automatically remove the oldest documents when the size limit is reached.
  • Use db.collection.stats() to verify the maxSize property of your capped collection.

Conclusion

MongoDB capped collections have no predefined maximum size limit. You can set any size value based on your storage requirements and available disk space.

Updated on: 2026-03-15T01:04:27+05:30

279 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements