I was using a PHP mongo command:
$db->command(array("create" => $name, "size" => $size, "capped" => true, "max" => $max));
And my collections grew way past their supposed capped limits. I put on a fix:
$db->createCollection($name, true, $size, $max);
Currently, the counts are so low I can't tell whether the 'fix' worked.
How can you tell if a collection is capped, either from the shell or PHP? I wasn't able to find this information in the system.namespaces.
Capped collections are fixed-size collections means when we create the collection, we must fix the maximum size of the collection(in bytes) and the maximum number of documents that it can store. After creation, if we try to add more than documents to their capacity, it overwrites the existing documents.
3. Which of the following collection is capped? Explanation: The database profiler writes data in the system. profile collection, which is a capped collection.
Convert a Collection to Capped You can convert a non-capped collection to a capped collection with the convertToCapped command: db. runCommand({"convertToCapped": "mycoll", size: 100000}); The size parameter specifies the size of the capped collection in bytes.
MongoDB Capped Collections is nothing but the circular collection's fixed size, which followed the insertion to support high performance for creating, delete and read operations. Circular capped collection states that when we allocate the fixed size to the collection, it was exhausted.
Turns out there's also the isCapped() function.
db.foo.isCapped()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With