Skip to main content

What is a capped collection and when should it be used?

Junior MongoDB
Quick Answer Capped collections have a fixed maximum size (in bytes) and optionally a max document count. When full, oldest documents are automatically overwritten by new ones (circular buffer). No deletes needed. Use for: logs, event streams, caches where only recent data matters. Insert order is maintained. Downside: can't delete individual documents, limited update operations.

Answer

A capped collection is a fixed-size collection where MongoDB overwrites old documents when full. It maintains insertion order and supports high-speed writes, useful for logs and metrics.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice