What is the MongoDB Capped Collection maximum allowable size?


It is up to you how much space you want. You need to use the parameter size to set. Use below syntax −

db.createCollection(‘yourCollectionName’, capped=true, size=yourValue);

Let us implement the above syntax in order to allow size for a capped collection −

> db.createCollection('cappedCollectionMaximumSize', capped=true, size=1948475757574646);
{ "ok" : 1 }

Let us check the description of the above collection −

> db.cappedCollectionMaximumSize.find().explain();

This will produce the following output −

{
   "queryPlanner" : {
      "plannerVersion" : 1,
      "namespace" : "test.cappedCollectionMaximumSize",
      "indexFilterSet" : false,
      "parsedQuery" : {
      },
      "winningPlan" : {
         "stage" : "COLLSCAN",
         "direction" : "forward"
      },
      "rejectedPlans" : [ ]
   },
   "serverInfo" : {
      "host" : "DESKTOP-QN2RB3H",
      "port" : 27017,
      "version" : "4.0.5",
      "gitVersion" : "3739429dd92b92d1b0ab120911a23d50bf03c412"
   },
   "ok" : 1
}

Updated on: 30-Jul-2019

156 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements