blob: 4748afb9a828c11ff64021e3ca8253865c02a6ab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
// test preservePadding
var mydb = db.getSiblingDB('compactPreservePadding');
var collName = "compactPreservePadding";
var t = mydb.getCollection(collName);
t.drop();
// use larger keyname to avoid hitting an edge case with extents
for (i = 0; i < 10000; i++) {
t.insert({useLargerKeyName:i});
}
// remove half the entries
t.remove({useLargerKeyName:{$mod:[2,0]}})
printjson(t.stats());
originalSize = t.stats().size;
originalStorage = t.stats().storageSize;
// compact!
mydb.runCommand({compact: collName, preservePadding: true});
printjson(t.stats());
// object sizes ('size') should be the same (unless we hit an edge case involving extents, which
// this test doesn't) and storage size should shrink
assert(originalSize == t.stats().size);
assert(originalStorage > t.stats().storageSize);
|