[mongodb-user] Collection Storage Size

2,731 views
Skip to first unread message

Fontana

unread,
May 24, 2010, 7:35:22 AM5/24/10
to mongodb-user
Hi,
I have one database with one collection which store 30,000,000
documents.
Each document has "_id" which is integer, and "v" which contains
binary data (~10K)
according to "db.foo.totalSize()" the storage size should be 320 GB.
When I checked the mongoDB folder with the OS, its size was 422 GB.
Why is there more than did 100 GB difference between the size
according to mongo and the actual size?

--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

Kristina Chodorow

unread,
May 24, 2010, 7:46:12 AM5/24/10
to mongod...@googlegroups.com
It's probably padding for document size changes: you can check what the ratio is using db.coll.stats() and looking at the paddingFactor field.

Also, Mongo doesn't reclaim space on deletes (it's assuming your db is going to get bigger again and it'll reuse the space) so if you've deleted a lot of documents, that might be why.

Fontana

unread,
May 24, 2010, 7:56:45 AM5/24/10
to mongodb-user
The paddingFactor is 1 (whatever that means).
I didn't delete anything from the collection just insert 30 million
one after the other.

100 GB is a lot of space. Is there a way to make it smaller?

On May 24, 2:46 pm, Kristina Chodorow <krist...@10gen.com> wrote:
> It's probably padding for document size changes: you can check what the
> ratio is using db.coll.stats() and looking at the paddingFactor field.
>
> Also, Mongo doesn't reclaim space on deletes (it's assuming your db is going
> to get bigger again and it'll reuse the space) so if you've deleted a lot of
> documents, that might be why.
>
>
>
> On Mon, May 24, 2010 at 7:35 AM, Fontana <idan.am...@gmail.com> wrote:
> > Hi,
> > I have one database with one collection which store 30,000,000
> > documents.
> > Each document has "_id" which is integer, and "v" which contains
> > binary data (~10K)
> > according to "db.foo.totalSize()" the storage size should be 320 GB.
> > When I checked the mongoDB folder with the OS, its size was 422 GB.
> > Why is there more than did 100 GB difference between the size
> > according to mongo and the actual size?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "mongodb-user" group.
> > To post to this group, send email to mongod...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > mongodb-user...@googlegroups.com<mongodb-user%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/mongodb-user?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/mongodb-user?hl=en.

Eliot Horowitz

unread,
May 24, 2010, 10:27:08 AM5/24/10
to mongod...@googlegroups.com
Can you send the output of db.stats() and the raw output of db.foo.stats() ?

Fontana

unread,
May 25, 2010, 4:24:44 AM5/25/10
to mongodb-user
I pasted them below.

> db.stats()
{
"collections" : 2,
"objects" : 32162401,
"dataSize" : 333588437936,
"storageSize" : 335517701376,
"numExtents" : 890,
"indexes" : 1,
"indexSize" : 1198080960,
"ok" : 1
}
> db.myCollection.stats()
{
"ns" : "myDatabase.myCollection",
"count" : 32162400,
"size" : 333588437860,
"storageSize" : 335517696768,
"numExtents" : 889,
"nindexes" : 1,
"lastExtentSize" : 1460622592,
"paddingFactor" : 1,
"flags" : 1,
"totalIndexSize" : 1198080960,
"indexSizes" : {
"_id_" : 1198080960
},
"ok" : 1
}

thanks.

Eliot Horowitz

unread,
May 25, 2010, 9:44:40 AM5/25/10
to mongod...@googlegroups.com
What version are you running?
If its below 1.4.2 there is a disk space inefficiency issue.

Suno Ano

unread,
May 25, 2010, 9:54:22 AM5/25/10
to mongod...@googlegroups.com
looks all fine to me, not sure why/how you checked from the OS?
something like du -sh? This gave you 422GiB?

I would be interested to see outputs from dh -sh and then these MongoDB
shell commands:
http://sunoano.name/ws/mongodb.html#how_can_i_tell_the_size_of_a_collection_and_its_indexes

Your stats from above are coherent, question is, why do you see 422GiB
from the OS being used (you said you did not delete stuff so ...).

Fontana

unread,
May 30, 2010, 2:39:22 AM5/30/10
to mongodb-user
Hi,
Sorry for the late response...
I'm running version 1.4.1
I'm using Windows Server OS, so I'm not really sure what "du -sh"
means.
I can show you the files in the folder using the dir /s command which
shows ~460 GB (It's pretty long)
and below it are the shell commands you asked me for:

Z:\28010>dir /S

Directory of Z:\28010

05/24/2010 07:08 AM <DIR> .
05/24/2010 01:08 AM <DIR> ..
05/24/2010 06:49 AM 16,777,216 myDatabase.ns
05/23/2010 04:52 AM 67,108,864 myDatabase.0
05/23/2010 04:52 AM 134,217,728 myDatabase.1
05/23/2010 08:09 AM 268,435,456 myDatabase.2
05/23/2010 08:09 AM 536,870,912 myDatabase.3
05/23/2010 04:55 AM 1,073,741,824 myDatabase.4
05/23/2010 08:16 AM 2,146,435,072 myDatabase.5
05/23/2010 08:09 AM 2,146,435,072 myDatabase.6
05/23/2010 05:03 AM 2,146,435,072 myDatabase.7
05/23/2010 08:23 AM 2,146,435,072 myDatabase.8
05/23/2010 05:09 AM 2,146,435,072 myDatabase.9
05/23/2010 08:22 AM 2,146,435,072 myDatabase.10
05/23/2010 05:17 AM 2,146,435,072 myDatabase.11
05/23/2010 05:26 AM 2,146,435,072 myDatabase.12
05/23/2010 05:24 AM 2,146,435,072 myDatabase.13
05/23/2010 05:35 AM 2,146,435,072 myDatabase.14
05/23/2010 05:30 AM 2,146,435,072 myDatabase.15
05/23/2010 05:32 AM 2,146,435,072 myDatabase.16
05/23/2010 05:46 AM 2,146,435,072 myDatabase.17
05/23/2010 05:39 AM 2,146,435,072 myDatabase.18
05/23/2010 05:43 AM 2,146,435,072 myDatabase.19
05/23/2010 07:41 AM 2,146,435,072 myDatabase.20
05/23/2010 05:51 AM 2,146,435,072 myDatabase.21
05/23/2010 05:54 AM 2,146,435,072 myDatabase.22
05/23/2010 05:57 AM 2,146,435,072 myDatabase.23
05/23/2010 05:59 AM 2,146,435,072 myDatabase.24
05/23/2010 08:09 AM 2,146,435,072 myDatabase.25
05/23/2010 06:06 AM 2,146,435,072 myDatabase.26
05/23/2010 06:10 AM 2,146,435,072 myDatabase.27
05/23/2010 06:14 AM 2,146,435,072 myDatabase.28
05/23/2010 08:09 AM 2,146,435,072 myDatabase.29
05/23/2010 06:20 AM 2,146,435,072 myDatabase.30
05/23/2010 06:23 AM 2,146,435,072 myDatabase.31
05/23/2010 06:25 AM 2,146,435,072 myDatabase.32
05/23/2010 07:40 AM 2,146,435,072 myDatabase.33
05/23/2010 07:43 AM 2,146,435,072 myDatabase.34
05/23/2010 07:48 AM 2,146,435,072 myDatabase.35
05/24/2010 02:10 AM 2,146,435,072 myDatabase.36
05/23/2010 07:55 AM 2,146,435,072 myDatabase.37
05/23/2010 07:58 AM 2,146,435,072 myDatabase.38
05/23/2010 08:00 AM 2,146,435,072 myDatabase.39
05/23/2010 08:03 AM 2,146,435,072 myDatabase.40
05/23/2010 08:06 AM 2,146,435,072 myDatabase.41
05/23/2010 11:55 PM 2,146,435,072 myDatabase.42
05/23/2010 08:14 AM 2,146,435,072 myDatabase.43
05/23/2010 08:23 AM 2,146,435,072 myDatabase.44
05/23/2010 08:26 AM 2,146,435,072 myDatabase.45
05/23/2010 08:30 AM 2,146,435,072 myDatabase.46
05/23/2010 08:32 AM 2,146,435,072 myDatabase.47
05/23/2010 08:34 AM 2,146,435,072 myDatabase.48
05/23/2010 08:37 AM 2,146,435,072 myDatabase.49
05/23/2010 08:41 AM 2,146,435,072 myDatabase.50
05/23/2010 08:45 AM 2,146,435,072 myDatabase.51
05/23/2010 08:50 AM 2,146,435,072 myDatabase.52
05/23/2010 08:52 AM 2,146,435,072 myDatabase.53
05/23/2010 08:56 AM 2,146,435,072 myDatabase.54
05/23/2010 08:58 AM 2,146,435,072 myDatabase.55
05/23/2010 09:59 AM 2,146,435,072 myDatabase.56
05/23/2010 09:04 AM 2,146,435,072 myDatabase.57
05/23/2010 09:08 AM 2,146,435,072 myDatabase.58
05/23/2010 09:12 AM 2,146,435,072 myDatabase.59
05/23/2010 09:16 AM 2,146,435,072 myDatabase.60
05/23/2010 09:19 AM 2,146,435,072 myDatabase.61
05/23/2010 09:22 AM 2,146,435,072 myDatabase.62
05/23/2010 09:24 AM 2,146,435,072 myDatabase.63
05/23/2010 09:27 AM 2,146,435,072 myDatabase.64
05/23/2010 09:30 AM 2,146,435,072 myDatabase.65
05/23/2010 09:33 AM 2,146,435,072 myDatabase.66
05/23/2010 09:38 AM 2,146,435,072 myDatabase.67
05/23/2010 09:42 AM 2,146,435,072 myDatabase.68
05/23/2010 09:45 AM 2,146,435,072 myDatabase.69
05/23/2010 09:48 AM 2,146,435,072 myDatabase.70
05/23/2010 09:50 AM 2,146,435,072 myDatabase.71
05/23/2010 09:53 AM 2,146,435,072 myDatabase.72
05/23/2010 09:56 AM 2,146,435,072 myDatabase.73
05/23/2010 11:20 AM 2,146,435,072 myDatabase.74
05/23/2010 10:04 AM 2,146,435,072 myDatabase.75
05/23/2010 10:08 AM 2,146,435,072 myDatabase.76
05/23/2010 10:12 AM 2,146,435,072 myDatabase.77
05/23/2010 10:14 AM 2,146,435,072 myDatabase.78
05/23/2010 10:17 AM 2,146,435,072 myDatabase.79
05/23/2010 10:19 AM 2,146,435,072 myDatabase.80
05/23/2010 10:22 AM 2,146,435,072 myDatabase.81
05/23/2010 10:26 AM 2,146,435,072 myDatabase.82
05/23/2010 10:30 AM 2,146,435,072 myDatabase.83
05/23/2010 10:34 AM 2,146,435,072 myDatabase.84
05/23/2010 10:38 AM 2,146,435,072 myDatabase.85
05/23/2010 10:40 AM 2,146,435,072 myDatabase.86
05/23/2010 10:43 AM 2,146,435,072 myDatabase.87
05/23/2010 10:45 AM 2,146,435,072 myDatabase.88
05/23/2010 10:49 AM 2,146,435,072 myDatabase.89
05/23/2010 10:52 AM 2,146,435,072 myDatabase.90
05/23/2010 10:56 AM 2,146,435,072 myDatabase.91
05/23/2010 11:01 AM 2,146,435,072 myDatabase.92
05/23/2010 11:08 AM 2,146,435,072 myDatabase.93
05/23/2010 11:14 AM 2,146,435,072 myDatabase.94
05/23/2010 11:18 AM 2,146,435,072 myDatabase.95
05/24/2010 02:10 AM 2,146,435,072 myDatabase.96
05/23/2010 11:24 AM 2,146,435,072 myDatabase.97
05/23/2010 11:27 AM 2,146,435,072 myDatabase.98
05/23/2010 11:32 AM 2,146,435,072 myDatabase.99
05/23/2010 11:36 AM 2,146,435,072 myDatabase.100
05/23/2010 11:39 AM 2,146,435,072 myDatabase.101
05/23/2010 11:42 AM 2,146,435,072 myDatabase.102
05/23/2010 11:45 AM 2,146,435,072 myDatabase.103
05/23/2010 11:47 AM 2,146,435,072 myDatabase.104
05/23/2010 11:50 AM 2,146,435,072 myDatabase.105
05/23/2010 11:54 AM 2,146,435,072 myDatabase.106
05/23/2010 11:58 AM 2,146,435,072 myDatabase.107
05/23/2010 12:02 PM 2,146,435,072 myDatabase.108
05/23/2010 12:05 PM 2,146,435,072 myDatabase.109
05/23/2010 12:08 PM 2,146,435,072 myDatabase.110
05/23/2010 12:11 PM 2,146,435,072 myDatabase.111
05/23/2010 12:13 PM 2,146,435,072 myDatabase.112
05/23/2010 12:17 PM 2,146,435,072 myDatabase.113
05/23/2010 12:20 PM 2,146,435,072 myDatabase.114
05/23/2010 12:24 PM 2,146,435,072 myDatabase.115
05/23/2010 12:28 PM 2,146,435,072 myDatabase.116
05/23/2010 12:32 PM 2,146,435,072 myDatabase.117
05/23/2010 12:34 PM 2,146,435,072 myDatabase.118
05/23/2010 12:37 PM 2,146,435,072 myDatabase.119
05/23/2010 12:39 PM 2,146,435,072 myDatabase.120
05/23/2010 12:42 PM 2,146,435,072 myDatabase.121
05/23/2010 02:29 PM 2,146,435,072 myDatabase.122
05/23/2010 12:50 PM 2,146,435,072 myDatabase.123
05/23/2010 12:54 PM 2,146,435,072 myDatabase.124
05/23/2010 12:57 PM 2,146,435,072 myDatabase.125
05/23/2010 01:01 PM 2,146,435,072 myDatabase.126
05/23/2010 01:03 PM 2,146,435,072 myDatabase.127
05/23/2010 01:05 PM 2,146,435,072 myDatabase.128
05/23/2010 01:09 PM 2,146,435,072 myDatabase.129
05/23/2010 01:12 PM 2,146,435,072 myDatabase.130
05/23/2010 01:16 PM 2,146,435,072 myDatabase.131
05/23/2010 01:21 PM 2,146,435,072 myDatabase.132
05/23/2010 01:24 PM 2,146,435,072 myDatabase.133
05/23/2010 01:27 PM 2,146,435,072 myDatabase.134
05/23/2010 01:29 PM 2,146,435,072 myDatabase.135
05/23/2010 01:32 PM 2,146,435,072 myDatabase.136
05/23/2010 01:34 PM 2,146,435,072 myDatabase.137
05/23/2010 01:38 PM 2,146,435,072 myDatabase.138
05/23/2010 01:43 PM 2,146,435,072 myDatabase.139
05/23/2010 01:47 PM 2,146,435,072 myDatabase.140
05/23/2010 01:50 PM 2,146,435,072 myDatabase.141
05/23/2010 01:53 PM 2,146,435,072 myDatabase.142
05/23/2010 01:55 PM 2,146,435,072 myDatabase.143
05/23/2010 01:58 PM 2,146,435,072 myDatabase.144
05/23/2010 02:02 PM 2,146,435,072 myDatabase.145
05/23/2010 02:04 PM 2,146,435,072 myDatabase.146
05/23/2010 02:09 PM 2,146,435,072 myDatabase.147
05/23/2010 02:13 PM 2,146,435,072 myDatabase.148
05/23/2010 02:17 PM 2,146,435,072 myDatabase.149
05/23/2010 02:19 PM 2,146,435,072 myDatabase.150
05/23/2010 02:22 PM 2,146,435,072 myDatabase.151
05/23/2010 02:25 PM 2,146,435,072 myDatabase.152
05/23/2010 02:27 PM 2,146,435,072 myDatabase.153
05/24/2010 02:10 AM 2,146,435,072 myDatabase.154
05/23/2010 02:35 PM 2,146,435,072 myDatabase.155
05/23/2010 02:40 PM 2,146,435,072 myDatabase.156
05/23/2010 02:42 PM 2,146,435,072 myDatabase.157
05/23/2010 02:46 PM 2,146,435,072 myDatabase.158
05/23/2010 02:48 PM 2,146,435,072 myDatabase.159
05/23/2010 02:50 PM 2,146,435,072 myDatabase.160
05/23/2010 02:54 PM 2,146,435,072 myDatabase.161
05/23/2010 02:58 PM 2,146,435,072 myDatabase.162
05/23/2010 03:02 PM 2,146,435,072 myDatabase.163
05/23/2010 03:06 PM 2,146,435,072 myDatabase.164
05/23/2010 03:09 PM 2,146,435,072 myDatabase.165
05/23/2010 03:12 PM 2,146,435,072 myDatabase.166
05/23/2010 03:15 PM 2,146,435,072 myDatabase.167
05/23/2010 03:17 PM 2,146,435,072 myDatabase.168
05/23/2010 03:20 PM 2,146,435,072 myDatabase.169
05/23/2010 03:24 PM 2,146,435,072 myDatabase.170
05/23/2010 03:28 PM 2,146,435,072 myDatabase.171
05/23/2010 03:33 PM 2,146,435,072 myDatabase.172
05/23/2010 03:36 PM 2,146,435,072 myDatabase.173
05/23/2010 03:39 PM 2,146,435,072 myDatabase.174
05/23/2010 03:41 PM 2,146,435,072 myDatabase.175
05/23/2010 03:44 PM 2,146,435,072 myDatabase.176
05/23/2010 03:47 PM 2,146,435,072 myDatabase.177
05/23/2010 03:51 PM 2,146,435,072 myDatabase.178
05/23/2010 03:55 PM 2,146,435,072 myDatabase.179
05/23/2010 03:59 PM 2,146,435,072 myDatabase.180
05/23/2010 04:02 PM 2,146,435,072 myDatabase.181
05/23/2010 04:05 PM 2,146,435,072 myDatabase.182
05/23/2010 04:08 PM 2,146,435,072 myDatabase.183
05/23/2010 04:10 PM 2,146,435,072 myDatabase.184
05/23/2010 04:13 PM 2,146,435,072 myDatabase.185
05/23/2010 04:17 PM 2,146,435,072 myDatabase.186
05/23/2010 04:21 PM 2,146,435,072 myDatabase.187
05/23/2010 04:25 PM 2,146,435,072 myDatabase.188
05/23/2010 04:28 PM 2,146,435,072 myDatabase.189
05/23/2010 04:32 PM 2,146,435,072 myDatabase.190
05/24/2010 06:49 AM 2,146,435,072 myDatabase.191
05/23/2010 04:36 PM 2,146,435,072 myDatabase.192
05/23/2010 04:40 PM 2,146,435,072 myDatabase.193
05/23/2010 04:43 PM 2,146,435,072 myDatabase.194
05/23/2010 04:47 PM 2,146,435,072 myDatabase.195
05/23/2010 04:52 PM 2,146,435,072 myDatabase.196
05/23/2010 04:55 PM 2,146,435,072 myDatabase.197
05/23/2010 04:58 PM 2,146,435,072 myDatabase.198
05/23/2010 05:00 PM 2,146,435,072 myDatabase.199
05/23/2010 05:03 PM 2,146,435,072 myDatabase.200
05/23/2010 05:07 PM 2,146,435,072 myDatabase.201
05/24/2010 02:01 AM 2,146,435,072 myDatabase.202
05/24/2010 02:11 AM 2,146,435,072 myDatabase.203
05/24/2010 02:19 AM 2,146,435,072 myDatabase.204
05/24/2010 02:24 AM 2,146,435,072 myDatabase.205
05/24/2010 02:30 AM 2,146,435,072 myDatabase.206
05/24/2010 02:34 AM 2,146,435,072 myDatabase.207
05/24/2010 02:39 AM 2,146,435,072 myDatabase.208
05/24/2010 04:47 AM 2,146,435,072 myDatabase.209
05/24/2010 04:59 AM 2,146,435,072 myDatabase.210
05/24/2010 05:09 AM 2,146,435,072 myDatabase.211
05/24/2010 05:19 AM 2,146,435,072 myDatabase.212
05/24/2010 05:26 AM 2,146,435,072 myDatabase.213
05/24/2010 05:34 AM 2,146,435,072 myDatabase.214
05/24/2010 06:46 AM 2,146,435,072 myDatabase.215
05/24/2010 06:49 AM 2,146,435,072 myDatabase.216
05/24/2010 06:49 AM 2,146,435,072 myDatabase.217
219 File(s) 459,287,822,336 bytes

Total Files Listed:
219 File(s) 459,287,822,336 bytes

The shell commands:

> db.myCollection.dataSize()
333588437860
> db.myCollection.storageSize()
335517696768
> db.myCollection.totalIndexSize()
1198080960
> db.myCollection.totalSize()
336715777728

> db.myCollection.validate()
{
"ns" : "myDatabase.myCollection",
"result" : "
validate
details: 00000000027770F0 ofs:fa70f0
firstExtent:0:2a00 ns:myDatabase.myCollection
lastExtent:d9:2000 ns:myDatabase.myCollection
# extents:889
datasize?:333588437860 nrecords?:32162400 lastExtentSize:1460622592
padding:1
first extent:
loc:0:2a00 xnext:0:4c400 xprev:null
nsdiag:myDatabase.myCollection
size:165888 firstRecord:0:2ab0 lastRecord:0:262c8
32135360 objects found, nobj:32162400
333822134352 bytes data w/headers
333307968592 bytes data wout/headers
deletedList: 0000001111000000001
?exception in deleted chain for bucket 7
?bad deleted loc: 30f000c:30eaee4 bucket:18 k:1
deleted: n: 699 size: 4807924
nIndexes:1
myDatabase.myCollection.$_id_ keys:32162582
ns corrupt, requires dbchk
",
"ok" : 1,
"valid" : false,
"lastExtentSize" : 1460622592
}


Thanks.



On May 25, 4:54 pm, Suno Ano <suno....@sunoano.org> wrote:
> looks all fine to me, not sure why/how you checked from the OS?
> something like du -sh? This gave you 422GiB?
>
> I would be interested to see outputs from dh -sh and then these MongoDB
> shell commands:http://sunoano.name/ws/mongodb.html#how_can_i_tell_the_size_of_a_coll...
Reply all
Reply to author
Forward
0 new messages