Well, probably this should be clear from the documentation, sadly, this is not the case. My guess was, that compact make some kind of defragmentation of the colection - such that collection's paddingfactor would go bellow given value. However, this does not seem to be true:
> db.aaa.stats().paddingFactor
1.9980000000000002
> db.runCommand ( { compact: 'aaa', paddingFactor: 1.1 } )
{ "ok" : 1 }
> db.aaa.stats().paddingFactor
1.9980000000000002
> db.runCommand ( { compact: 'aaa', paddingFactor: 3 } )
{ "ok" : 1 }
> db.aaa.stats().paddingFactor
1.9980000000000002
If this is not the way to change the padding factor of a collection, is there some other way to do so?
Yes. It rewrites, DE-fragments all the data and the indexes on the collection.
No. It does not change the padding factor of the collection.
From the docs:
So when you execute the below command,
the record size of the existing documents in the collection get altered using the specified padding factor. That is, all the existing records will now have
10%
of theirdocument size
as theirpadding
size.So after the DE-fragmentation all the existing records will have their sizes altered as,
And it does not the affect or change padding factor for the entire collection.
No. You can't select nor change the padding factor for a collection. From the docs: