#Capped Collections
Overview
Capped collections are fixed-size collections that support high-throughput operations that insert and retrieve documents based on insertion order. Capped collections work in a way similar to circular buffers: once a collection fills its allocated space, it makes room for new documents by overwriting the oldest documents in the collection.
#Restrictions and Recommendations
Updates
If you plan to update documents in a capped collection, create an index so that these update operations do not require a collection scan.
Document Size
Changed in version 3.2.
If an update or a replacement operation changes the document size, the operation will fail.
Document Deletion
You cannot delete documents from a capped collection. To remove all documents from a collection, use the drop() method to drop the collection and recreate the capped collection.
Sharding
You cannot shard a capped collection.
Query Efficiency
Use natural ordering to retrieve the most recently inserted elements from the collection efficiently. This is (somewhat) analogous to tail on a log file.
Aggregation $out
The aggregation pipeline operator $out cannot write results to a capped collection.