Why are my mongodb indices so large

I have 57M documents in my mongodb collection, which is 19G of data. My indexes occupy 10G. This sounds normal, or I can do something very wrong! My primary key is 2G.

{
        "ns" : "myDatabase.logs",
        "count" : 56795183,
        "size" : 19995518140,
        "avgObjSize" : 352.0636272974065,
        "storageSize" : 21217578928,
        "numExtents" : 39,
        "nindexes" : 4,
        "lastExtentSize" : 2146426864,
        "paddingFactor" : 1,
        "flags" : 1,
        "totalIndexSize" : 10753999088,
        "indexSizes" : {
            "_id_" : 2330814080,
            "type_1_playerId_1" : 2999537296,
            "type_1_time_-1" : 2344582464,
            "type_1_tableId_1" : 3079065248
        },
        "ok" : 1
    }
+3
source share
1 answer

The size of the index is determined by the number of indexed documents, as well as the size of the key (composite keys store more information and will be more). In this case, the _id index, divided by the number of documents, is 40 bytes, which seems relatively reasonable.

db.collection.getIndexes(), . {v: 0}, mongo 2.0, {v: 1}. : http://www.mongodb.org/display/DOCS/Index+Versions

+4

All Articles