Python获取mongo文档的size大小

版权声明:本文为博主原创,转载请注明出处。 https://blog.csdn.net/Chihwei_Hsu/article/details/83501555

使用bson模块得到mongo返回文档大小

import bson
res = db['log'].find_one({"sid": test_id})
print len(bson.BSON.encode(res)) # B
print len(bson.BSON.encode(res))*1.0/1024/1024 # MB
print len(bson.BSON.encode(res))*1.0/1024/1024/n

猜你喜欢

转载自blog.csdn.net/Chihwei_Hsu/article/details/83501555