Background MongoDB Index Size

I create an index ({a: 1, b: -1}), one of the foregrounds and others doing in the background. Check the total size of the index. Foreground: 82536720 Background: 154927024

Can someone tell me why there is a huge size difference?

Mongo > db.testing.ensureIndex({a:1,b:-1}) Mongo > db.testing.stats() { "ns" : "test.testing", "count" : 2402158, "size" : 86479836, "avgObjSize" : 36.00089419596879, "totalIndexSize" : 160486704, "indexSizes" : { "_id_" : 77949984, "a_1_b_-1" : 82536720 }, } Mongo > db.testing.dropIndexes() Mongo > db.testing.ensureIndex({a:1,b:-1},{background : true}) Mongo > db.testing.stats() { "count" : 2402158, "size" : 86479836, "avgObjSize" : 36.00089419596879, "totalIndexSize" : 232877008, "indexSizes" : { "_id_" : 77949984, "a_1_b_-1" : 154927024 }, } 
+4
source share
1 answer

MongoDB documentation says

The construction of the background index allows you to continue reading and writing operations when building the index; however, these index constructions take longer and end with a larger index.

So it is not surprising. Basically, mongo uses a different mechanism for creating a background index than the foreground index, which, among other things, causes the final index to be larger.

+5
source

Source: https://habr.com/ru/post/1479457/


All Articles