1

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?

Daniel F
  • 13,684
  • 11
  • 87
  • 116

1 Answers1

1

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.

profesor79
  • 9,213
  • 3
  • 31
  • 52
  • Thanks for the explanation. I tested it (some weeks ago) on a duplicate dataset and saw that all was OK, so i just applied it to the live dataset. It worked, and up until your explanation I was wondering why. It just didn't come into my mind that they would reuse the freed space... shame on me. – Daniel F Jun 26 '16 at 08:55