Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
What is the MongoDB Capped Collection maximum allowable size?
MongoDB capped collections can be set to any size you specify using the size parameter. There is no fixed maximum limit − the size is constrained only by your available disk space and system resources.
Syntax
db.createCollection('collectionName', {
capped: true,
size: sizeInBytes
});
Example
Create a capped collection with a large size limit ?
db.createCollection('cappedCollectionMaximumSize', {
capped: true,
size: 1948475757574646
});
{ "ok" : 1 }
Verify Collection Properties
Check the collection statistics to confirm the size setting ?
db.cappedCollectionMaximumSize.stats();
{
"ns" : "test.cappedCollectionMaximumSize",
"size" : 0,
"count" : 0,
"storageSize" : 4096,
"capped" : true,
"max" : NumberLong("9223372036854775807"),
"maxSize" : NumberLong("1948475757574646"),
"ok" : 1
}
Key Points
- The
sizeparameter accepts values in bytes. - MongoDB will automatically remove the oldest documents when the size limit is reached.
- Use
db.collection.stats()to verify themaxSizeproperty of your capped collection.
Conclusion
MongoDB capped collections have no predefined maximum size limit. You can set any size value based on your storage requirements and available disk space.
Advertisements
