How to determine index size using pymongo?

With monogdb, I can run db.collection.stats() to find the size in bytes for each index.

PyMongo seems to be skipping this operation.

Is there any way to find this information in PyMongo?

+4
source share
1 answer
 import pymongo connect = pymongo.Connection('mongodb://localhost', safe=True) db = connect.test db.command('collStats', 'collection') 

Result:

 { u'count': 2, u'ns': u'test.test2', u'ok': 1.0, u'lastExtentSize': 8192, u'avgObjSize': 94.0, u'totalIndexSize': 8176, u'systemFlags': 1, u'userFlags': 0, u'numExtents': 1, u'nindexes': 1, u'storageSize': 8192, u'indexSizes': {u'_id_': 8176}, u'paddingFactor': 1.0, u'size': 188 } 

PS test2 As a result, my collection name

+8
source

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


All Articles