18. • > show dbs
admin (empty)
local 25.94140625GB
test 29.939453125GB
• > use test
switched to db test
• > show collections
system.indexes
test0
test1
test2
44. 查找—使用limit提升性能
–使用limit提高效率
• 如果某次查询只想取一部分数据,那请使用limit吧。
#插入 10W行记录,每个1KB
for i in range(100000):
mycollection.insert({"_id":i, "name":"AAAAABBBBB"*100})
#不使用limit,使用了: 98714 ms
for j in range(10000):
for i,c in enumerate(mycollection.find({})):
if i >= 10:
break
#使用limit,使用了: 15558 ms
for j in range(10000):
for i,c in enumerate(mycollection.find({}).limit(10)):
pass