re: https://groups.google.com/group/mongodb-user/browse_thread/thread/6df6a4aa7101c2b7?hl=en#
New space always allocated even when currently allocated fileSize is large compared to storageSize.
simple example:
1.using mongoinsert inserting 1-2 GB data to one collection.
2.remove all records from collection
3.compact collection
4.querying db.stats().
5.repeat.
I expected allocated disk to grow with initial insert, remove and compact. I do not expect to see filesize grow on subsequent iterations of the same. I assumed it would reuse the space it knew it had free. That seems not to be the case. Before the last insert, there is approx fileSize-storageSize = 12GB
available.
> //loading 2 mil thingies using mongoimport
> db.stats()
> db.thingies.remove()
> db.thingies.runCommand('compact')
> db.stats()
{ "db" : "mango", "collections" : 3, "objects" : 4, "avgObjSize" : 45, "dataSize" : 180, "storageSize" : 721420288, "numExtents" : 3, "indexes" : 1, "indexSize" : 8176, "fileSize" : 6373244928, "nsSizeMB" : 16, "ok" : 1 } > //add the 2 mill again using mongoimport > db.stats() { "db" : "mango", "collections" : 3, "objects" : 2047904, "avgObjSize" : 1571.7465193680953, "dataSize" : 3218785984, "storageSize" : 3872567296, "numExtents" : 6, "indexes" : 1, "indexSize" : 79675120, "fileSize" : 10666115072, "nsSizeMB" : 16, "ok" : 1 } > db.thingies.remove() > db.thingies.runCommand('compact') { "ok" : 1 }> db.stats()
{
"db" : "mango",
"collections" : 3,
"objects" : 4,
"avgObjSize" : 45,
"dataSize" : 180,
"storageSize" : 1495941120,
"numExtents" : 3,
"indexes" : 1,
"indexSize" : 8176,
"fileSize" : 12812550144,
"nsSizeMB" : 16,
"ok" : 1
}
> //load them one more time using mongoimport
> db.stats()
{
"db" : "mango",
"collections" : 3,
"objects" : 2047904,
"avgObjSize" : 1571.7464666312483,
"dataSize" : 3218785876,
"storageSize" : 3291062272,
"numExtents" : 4,
"indexes" : 1,
"indexSize" : 79748704,
"fileSize" : 14958985216,
"nsSizeMB" : 16,
"ok" : 1
}
//we now have 14+ GB allocated to Mongo but only 3 in use.
- is related to
-
SERVER-3791 compact always creates a new extent
- Closed