我有一个向量集合集合的大小
print vectors.count()
是
102020
当我遍历字段时
start = time.time()
for v in vectors.find({},{'vector' : 1, '_id' : 0}):
pass
print "total time:" , end-start
总时间:5.05100011826
but when I run with explain() I see that the query takes substantially less time.
print vectors.find({},{'vector' : 1, '_id' : 0}).explain()
{u'nYields': 0, u'allPlans': [{u'cursor': u'BasicCursor', u'indexBounds': {}}], u'nChunkSkips': 0, u'millis': 23, u'n': 102020, u'cursor': u'BasicCursor', u'indexBounds': {}, u'nscannedObjects': 102020, u'isMultiKey': False, u'indexOnly': False, u'nscanned': 102020}
Why is there such a huge time difference? Is there anyway to speed this up? I loaded all of the vectors to a sql DB text field and the same query was less than one second. Thanks