difference betwwen show dbs and db.stats() displayed size

1,311 views
Skip to first unread message

Grégoire Seux

unread,
May 20, 2011, 11:35:57 AM5/20/11
to mongod...@googlegroups.com
Hello,


after a quite massive batch of operations on a collection, I would like to see the size of the resulting collection.
db.myCollection.stats()  and db.stats() display roughly the same size (myCollection is the only collection except system.indexes)
but show dbs  gives a third value (higher)

db.stats()
{
        "db" : "test",
        "collections" : 3,
        "objects" : 797161,
        "avgObjSize" : 876.5956488087099,
        "dataSize" : 698787864,
        "storageSize" : 755207424,
        "numExtents" : 20,
        "indexes" : 2,
        "indexSize" : 72441856,
        "fileSize" : 2080374784,
        "ok" : 1
}

 db.myCollection.stats()
{
        "ns" : "test.myCollection",
        "count" : 797155,
        "size" : 698787456,
        "avgObjSize" : 876.6017349198086,
        "storageSize" : 755197952,
        "numExtents" : 18,
        "nindexes" : 2,
        "lastExtentSize" : 137896960,
        "paddingFactor" : 1.0099999999984628,
        "flags" : 1,
        "totalIndexSize" : 72441856,
        "indexSizes" : {
                "_id_" : 33234944,
                "id_1" : 39206912
        },
        "ok" : 1
}

show dbs
admin   (empty)
local   6.2001953125GB
test    1.953125GB

Is there a explaination ? My guess woulb show dbs displays the allocated space whereas stats functions display the used space but I did'nt find any confirmation.

Thanks by advance for any reply

-- 
Grégoire Seux

Brendan W. McAdams

unread,
May 20, 2011, 2:15:02 PM5/20/11
to mongodb-user
The size shown in "show dbs" is the amount of storage actually
allocated on disk, rather than that being used.

Storage Size is the total amount of used storage by the data --- not
the total allocated but the total with padding that the actual data
(with indexes) is stored as.


For a bit more information on the disk allocation and why it differs
from the amount of data used, see:

http://www.mongodb.org/display/DOCS/Excessive+Disk+Space

Note that we don't "shrink" the files on disk if you delete any data.

Grégoire Seux

unread,
May 23, 2011, 5:02:17 AM5/23/11
to mongod...@googlegroups.com
thanks for your answer and for the link !
Reply all
Reply to author
Forward
0 new messages