Disadvantages of Capped Collections
- The update operation fails if the update of a document exceeds the original size of the collection.
- Deleting documents from a capped collection is not possible. If you want to delete all records from a capped collection, then use the given command:
{ emptycapped: Collection_name }
- Capped collection cant be shard.
Capped Collections in MongoDB
Capped collections are fixed-size collections means when we create the collection, we must fix the maximum size of the collection(in bytes) and the maximum number of documents that it can store. After creation, if we try to add more than documents to their capacity, it overwrites the existing documents. It supports high-throughput operations, that are useful when we insert and retrieve documents based on insertion order. The working of the capped collection is similar to circular buffers, which means once the fixed space is allocated for the capped collection, it creates/makes spaces for the new documents by overwriting the oldest documents in the given collection. Capped collection can also have _id field and by default, each _id field has an index.
Contact Us