How can you determine if a collection is limited?
I used the PHP mongo command:
$db->command(array("create" => $name, "size" => $size, "capped" => true, "max" => $max));
And my collections grew far from their supposed limitations. I put on the fix:
$db->createCollection($name, true, $size, $max);
Currently the counts are so low that I canβt determine if the fix worked.
How can you determine if a collection is limited, either from a shell or from PHP? I could not find this information in the system.names namespace.
In the shell, use db.collection.stats (). If the collection is limited:
> db.my_collection.stats()["capped"]
1
If the collection is not limited, the capped key will not be present.
The following are examples from stats () for a private collection:
> db.my_coll.stats()
{
"ns" : "my_db.my_coll",
"count" : 221,
"size" : 318556,
"avgObjSize" : 1441.4298642533936,
"storageSize" : 1000192,
"numExtents" : 1,
"nindexes" : 0,
"lastExtentSize" : 1000192,
"paddingFactor" : 1,
"flags" : 0,
"totalIndexSize" : 0,
"indexSizes" : {
},
"capped" : 1,
"max" : 2147483647,
"ok" : 1
}
This is with MongoDB 1.7.4.