Last active
August 29, 2015 14:23
-
-
Save kgorman/1c39f6dce753bb6703e5 to your computer and use it in GitHub Desktop.
Compaction/Fragmentation example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// mongodb 2.4.8 | |
// fragmented | |
// initial setting of random rand of 5000 | |
> use sbtest | |
switched to db sbtest | |
> db.stats() | |
{ | |
"db" : "sbtest", | |
"collections" : 19, | |
"objects" : 4000088, | |
"avgObjSize" : 2670.082581183214, | |
"dataSize" : 10680565292, | |
"storageSize" : 12709412864, | |
"numExtents" : 270, | |
"indexes" : 34, | |
"indexSize" : 250479936, | |
"fileSize" : 14471921664, | |
"nsSizeMB" : 16, | |
"dataFileVersion" : { | |
"major" : 4, | |
"minor" : 5 | |
}, | |
"ok" : 1 | |
} | |
> db.repairDatabase(); | |
{ "ok" : 1 } | |
> db.stats() | |
{ | |
"db" : "sbtest", | |
"collections" : 19, | |
"objects" : 4000088, | |
"avgObjSize" : 2649.1415768853085, | |
"dataSize" : 10596799432, | |
"storageSize" : 12838596608, | |
"numExtents" : 270, | |
"indexes" : 34, | |
"indexSize" : 201734624, | |
"fileSize" : 14471921664, | |
"nsSizeMB" : 16, | |
"dataFileVersion" : { | |
"major" : 4, | |
"minor" : 5 | |
}, | |
"ok" : 1 | |
} | |
> | |
//dump, restored | |
> db.stats() | |
{ | |
"db" : "sbtest", | |
"collections" : 19, | |
"objects" : 4000088, | |
"avgObjSize" : 2649.1418368795885, | |
"dataSize" : 10596800472, | |
"storageSize" : 12899418112, | |
"numExtents" : 249, | |
"indexes" : 34, | |
"indexSize" : 212723168, | |
"fileSize" : 14471921664, | |
"nsSizeMB" : 16, | |
"dataFileVersion" : { | |
"major" : 4, | |
"minor" : 5 | |
}, | |
"ok" : 1 | |
} | |
// now if we start with range of 0-25000, then subsequently choose 5000, then we get more fragmentation | |
> use sbtest | |
switched to db sbtest | |
> db.stats() | |
{ | |
"db" : "sbtest", | |
"collections" : 19, | |
"objects" : 400087, | |
"avgObjSize" : 12608.630502865626, | |
"dataSize" : 5044549152, | |
"storageSize" : 6062137344, | |
"numExtents" : 215, | |
"indexes" : 34, | |
"indexSize" : 27659408, | |
"fileSize" : 6959398912, | |
"nsSizeMB" : 16, | |
"dataFileVersion" : { | |
"major" : 4, | |
"minor" : 5 | |
}, | |
"ok" : 1 | |
} | |
> db.repairDatabase(); | |
{ "ok" : 1 } | |
> db.stats() | |
{ | |
"db" : "sbtest", | |
"collections" : 19, | |
"objects" : 400087, | |
"avgObjSize" : 12088.398953227674, | |
"dataSize" : 4836411272, | |
"storageSize" : 5714386944, | |
"numExtents" : 212, | |
"indexes" : 34, | |
"indexSize" : 20423648, | |
"fileSize" : 6959398912, | |
"nsSizeMB" : 16, | |
"dataFileVersion" : { | |
"major" : 4, | |
"minor" : 5 | |
}, | |
"ok" : 1 | |
} | |
> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment