Index Size Growth on updateMany()

When I update an indexed field, the index size grows so much. What’s the reason behind this? (Values of the indexed fields were ‘deneme’ in all the documents before the update.)

One thing i can think of is that old index tree is still there and yet to be deleted. Try running the updateMany a few more times and see if it keeps growing.

yes, it keeps growing.

If the

I would expect

Before you had 1 key in your index that was pointing to all documents.

After you have many keys in your index, each key pointing to a subset of documents.

More keys in an index necessarily imply a bigger index size.

I got same problem, I find the index size keep growing in fast

I see the same thing. frequently updated index grows from 150 Mb to over 5 Gb in size. I update record timestamps, but some records can live for longer time. I guess this keeps index pages used and mongodb cannot release it. don’t think there is easy way out, apart for limiting retention period (I delete records after some time). otherwise some option to rebalance indices in mongo would be nice. not sure if doable.