<br />
<b>Warning</b>:  Undefined array key "global_protection_id" in <b>/home/wikitechy/public_html/interview-questions/wp-content/plugins/content-protector/inc/class-ps-rest-handler.php</b> on line <b>51</b><br />
{"id":4100,"date":"2022-04-13T09:51:53","date_gmt":"2022-04-13T09:51:53","guid":{"rendered":"https:\/\/www.wikitechy.com\/interview-questions\/?p=4100"},"modified":"2022-04-13T09:54:19","modified_gmt":"2022-04-13T09:54:19","slug":"what-is-the-use-of-capped-collection-in-mongodb","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-is-the-use-of-capped-collection-in-mongodb\/","title":{"rendered":"What is the use of Capped Collection in MongoDB ?"},"content":{"rendered":"<ul>\n<li>Capped collections are fixed-size collections means when we create the collection, we must fix the maximum size of the collection (in bytes) and it can store the maximum number of documents.<\/li>\n<li>After creation, it overwrites the existing documents, when we try to add more than documents to their capacity.<\/li>\n<li>They are useful when we insert and retrieve documents based on insertion order, it supports high-throughput operations.<\/li>\n<li>It is similar to circular buffers, which means once the fixed space is allocated for the capped collection.<\/li>\n<li>Capped collection can also have _id field and by default, each _id field has an index.<\/li>\n<li>In this collection, there are two parameters:<\/li>\n<\/ul>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol style=\"text-align: justify;\">\n<li>Name- It represents the name of the collection and it is of string type.<\/li>\n<li>Options<strong>&#8211;<\/strong>It is an optional parameter.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p><strong>Syntax:<\/strong><\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-4103\" src=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/capped-collection-in-mongodb.png\" alt=\"\" width=\"1426\" height=\"168\" srcset=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/capped-collection-in-mongodb.png 1426w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/capped-collection-in-mongodb-300x35.png 300w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/capped-collection-in-mongodb-1024x121.png 1024w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/capped-collection-in-mongodb-768x90.png 768w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/capped-collection-in-mongodb-390x46.png 390w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/capped-collection-in-mongodb-820x97.png 820w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/capped-collection-in-mongodb-1180x139.png 1180w\" sizes=\"(max-width: 1426px) 100vw, 1426px\" \/><\/p>\n<p>This syntax specifies the following fields:<\/p>\n<ol>\n<li><strong>Collection Name:<\/strong> It is used to create as capped collection.<\/li>\n<li><strong>Capped:<\/strong> It is a Boolean field. If it is true, we create a capped collection.<\/li>\n<li><strong>auto indexed:<\/strong> It is a Boolean flag and use for auto-indexing. Indexes will be created automatically, if the flag is true.<\/li>\n<li><strong>Size:<\/strong> The maximum number of documents in bytes is represented by size. In context of capped collection, this is required field.<\/li>\n<li><strong>Max:<\/strong> The highest number of documents that permit the collection was represented by max.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Capped collections are fixed-size collections means when we create the collection, we must fix the maximum size of the collection (in bytes) and it can store the maximum number of documents. After creation, it overwrites the existing documents, when we try to add more than documents to their capacity. They are useful when we insert [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"passster_activate_protection":false,"passster_protect_child_pages":"","passster_protection_type":"password","passster_password":"","passster_activate_overwrite_defaults":"","passster_headline":"","passster_instruction":"","passster_placeholder":"","passster_button":"","passster_id":"","passster_activate_misc_settings":"","passster_redirect_url":"","passster_hide":"no","passster_area_shortcode":"","gtb_hide_title":false,"gtb_wrap_title":false,"gtb_class_title":"","gtb_remove_headerfooter":false,"footnotes":""},"categories":[16831],"tags":[16937,16936,16940,16944,16943,16939,16938,16941,16945,16946,16942],"class_list":["post-4100","post","type-post","status-publish","format-standard","hentry","category-mongodb","tag-capped-collections","tag-capped-collections-in-mongodb","tag-functions-of-mongodb-capped-collections","tag-how-to-remove-a-document-from-a-capped-collection-in-mongodb","tag-how-to-remove-capped-collection-in-mongodb","tag-mongodb-capped-collection","tag-mongodb-capped-collections","tag-what-are-capped-collections-in-mongodb","tag-what-is-capped-collection","tag-what-is-the-use-of-capped-collection-in-mongodb","tag-what-is-the-use-of-capped-collections-in-mongodb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is the use of Capped Collection in MongoDB ? - MongoDB<\/title>\n<meta name=\"description\" content=\"What is the use of Capped Collection in MongoDB ? - Capped collections are fixed-size collections means when we create the collection\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-is-the-use-of-capped-collection-in-mongodb\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is the use of Capped Collection in MongoDB ? - MongoDB\" \/>\n<meta property=\"og:description\" content=\"What is the use of Capped Collection in MongoDB ? - Capped collections are fixed-size collections means when we create the collection\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-is-the-use-of-capped-collection-in-mongodb\/\" \/>\n<meta property=\"og:site_name\" content=\"Wikitechy\" \/>\n<meta property=\"article:published_time\" content=\"2022-04-13T09:51:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-04-13T09:54:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/capped-collection-in-mongodb.png\" \/>\n<meta name=\"author\" content=\"webmaster\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"webmaster\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-is-the-use-of-capped-collection-in-mongodb\/\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-is-the-use-of-capped-collection-in-mongodb\/\",\"name\":\"What is the use of Capped Collection in MongoDB ? - MongoDB\",\"isPartOf\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-is-the-use-of-capped-collection-in-mongodb\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-is-the-use-of-capped-collection-in-mongodb\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/capped-collection-in-mongodb.png\",\"datePublished\":\"2022-04-13T09:51:53+00:00\",\"dateModified\":\"2022-04-13T09:54:19+00:00\",\"author\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\"},\"description\":\"What is the use of Capped Collection in MongoDB ? - Capped collections are fixed-size collections means when we create the collection\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-is-the-use-of-capped-collection-in-mongodb\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-is-the-use-of-capped-collection-in-mongodb\/#primaryimage\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/capped-collection-in-mongodb.png\",\"contentUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/capped-collection-in-mongodb.png\",\"width\":1426,\"height\":168},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/\",\"name\":\"Wikitechy\",\"description\":\"Interview Questions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\",\"name\":\"webmaster\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"caption\":\"webmaster\"},\"sameAs\":[\"https:\/\/www.wikitechy.com\/interview-questions\"],\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is the use of Capped Collection in MongoDB ? - MongoDB","description":"What is the use of Capped Collection in MongoDB ? - Capped collections are fixed-size collections means when we create the collection","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-is-the-use-of-capped-collection-in-mongodb\/","og_locale":"en_US","og_type":"article","og_title":"What is the use of Capped Collection in MongoDB ? - MongoDB","og_description":"What is the use of Capped Collection in MongoDB ? - Capped collections are fixed-size collections means when we create the collection","og_url":"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-is-the-use-of-capped-collection-in-mongodb\/","og_site_name":"Wikitechy","article_published_time":"2022-04-13T09:51:53+00:00","article_modified_time":"2022-04-13T09:54:19+00:00","og_image":[{"url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/capped-collection-in-mongodb.png"}],"author":"webmaster","twitter_card":"summary_large_image","twitter_misc":{"Written by":"webmaster","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-is-the-use-of-capped-collection-in-mongodb\/","url":"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-is-the-use-of-capped-collection-in-mongodb\/","name":"What is the use of Capped Collection in MongoDB ? - MongoDB","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-is-the-use-of-capped-collection-in-mongodb\/#primaryimage"},"image":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-is-the-use-of-capped-collection-in-mongodb\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/capped-collection-in-mongodb.png","datePublished":"2022-04-13T09:51:53+00:00","dateModified":"2022-04-13T09:54:19+00:00","author":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4"},"description":"What is the use of Capped Collection in MongoDB ? - Capped collections are fixed-size collections means when we create the collection","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-is-the-use-of-capped-collection-in-mongodb\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-is-the-use-of-capped-collection-in-mongodb\/#primaryimage","url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/capped-collection-in-mongodb.png","contentUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/04\/capped-collection-in-mongodb.png","width":1426,"height":168},{"@type":"WebSite","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website","url":"https:\/\/www.wikitechy.com\/interview-questions\/","name":"Wikitechy","description":"Interview Questions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4","name":"webmaster","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","caption":"webmaster"},"sameAs":["https:\/\/www.wikitechy.com\/interview-questions"],"url":"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/comments?post=4100"}],"version-history":[{"count":3,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4100\/revisions"}],"predecessor-version":[{"id":4104,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4100\/revisions\/4104"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/media?parent=4100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/categories?post=4100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/tags?post=4100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}