Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you tell if a collection is capped?

Tags:

php

mongodb

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.

like image 861
buley Avatar asked Jan 18 '11 00:01

buley


People also ask

What are the characteristics of capped collection?

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.

Which of the following collections is capped?

3. Which of the following collection is capped? Explanation: The database profiler writes data in the system. profile collection, which is a capped collection.

How do you turn a collection into 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.

What is capped collection?

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.


1 Answers

Turns out there's also the isCapped() function.

db.foo.isCapped()
like image 190
buley Avatar answered Oct 06 '22 03:10

buley