Search code examples
mongodbcapped-collections

What size is capped in mongodb capped collection?


When specifying the 'size' parameter for a capped collection, which of the following sizes from db.collection.stats() is capped to that size? is it "size", "storageSize", "storageSize"+"totalIndexSize" or some other option? Thanks!


Solution

  • According to the documentation:

    Optional. Specifies a maximum size in bytes for a capped collection. The size field is required for capped collections. If capped is false, you can use this field to preallocate space for an ordinary collection.

    So I would assume it is storageSize.

    This would also suggest it is limited on storageSize:

    https://jira.mongodb.org/browse/SERVER-5615

    Where Elliot says:

    Indexes don't count within the capped size. The capped size is for data alone. Indexes do use space, but b-trees have up to 50% extra space because of balancing. The guarantee is that it'll never be more than 50%.