One of the collections has documents with a field "sc":[float]
. I want to iterate all documents and change this to "sc": float
, that is, remove the array and assign the float value directly to the key.
Isn't it true, that WiredTiger appends all updated documents instead of trying to do some in-place updates like MMap?
This would basically double the size of the database, with the initial half being obsolete data.
Do I need to call mongod -repair
in order to discard those obsolete documents, or is there something else I need to do?
WT is always rewriting documents when updated, but instead of NMAP it is not using padding, and allocating documents in free blocks, so if we have document 1,2,3 - there is a chance that no1 will be moved to end of a file (or closest gap), and no2 will be allocated in previous no1 space.
what is important about WT:
WiredTiger does ongoing compaction and reuse of space automatically.
To ensure that file is used efficiency we can enforce WT to use smaller page size as per this discussion.
--wiredTigerCollectionConfigString="leaf_page_max=8KB"
Also compact
could be use to reclaim space more here.