With monogdb, I can run db.collection.stats()
to find the size, in bytes, for each index.
PyMongo seems to be missing this operation.
Is there a way to find this information with PyMongo?
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
}
P.S. test2
in the result is my collection name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With