Getting Max Size for Capped Collection

102 views
Skip to first unread message

TwoStep

unread,
Apr 30, 2015, 11:59:24 AM4/30/15
to mongod...@googlegroups.com
Hello all:

I am trying to get the max size of a collection I know to be capped. However, when I do a db.collection.stats() I am not presented with the 'maxsize' number as I expected from the documentation here:


All I get is the following:

//
        "capped" : true,
        "max" : NumberLong("9223372036854775807"),
        "ok" : 1
}

I expected there to be a maxsize in there somewhere with the limit I set for the collection. Am I missing something? 

Dwight Merriman

unread,
May 1, 2015, 10:51:44 AM5/1/15
to mongod...@googlegroups.com
the max field you show is the max size?

Stephen Dillon

unread,
May 1, 2015, 11:54:57 AM5/1/15
to mongod...@googlegroups.com
I see your point, regarding the documentation. The max field, as per the documentation, only "Shows the maximum number of documents that may be present in a capped collection." whereas maxSize shows "the maximum size of a capped collection."

What version of MongoDB are you running?

I ran this as well. In version 3.0.2 I do see maxSize on a capped collection I created. I tried this in both my own test db as well as the local DB. However in version 2.6.9 I only see "max" on the oplog.rs collection and I also created a new capped collection against the local DB and it still failed to be displayed. I used the same command to create the capped collection on both versions. 

Could it be this documentation you are referencing is 3.0+ specific? Usually they reference the changes within the documentation but perhaps I missed it.

On Thursday, April 30, 2015 at 11:59:24 AM UTC-4, TwoStep wrote:

TwoStep

unread,
May 1, 2015, 12:12:59 PM5/1/15
to mongod...@googlegroups.com
No - the max size field appears to be missing from the output, which is what I am concerned about?

TwoStep

unread,
May 1, 2015, 4:43:08 PM5/1/15
to mongod...@googlegroups.com
Good point Stephen. I am using 2.6.9 and perhaps that is not a feature for this specific version. I did not see anything stating that in the docs itself however. Does that mean I am out of luck for 2.6.9?
Reply all
Reply to author
Forward
0 new messages