python:为什么处理的文档多于集合中的文档数

时间:2015-04-20 17:32:53

标签: python mongodb collections count document

我在mongo集合上使用for循环并更新每个文档。要检查已处理的文档数量,我使用枚举,我的代码如下:

for r, d_100 in enumerate(grid100.find().batch_size(1000)):
    self_grid = grid100.find({'_id':d_100['_id']})
    ......
    ......
    (processing)
    grid100.update({'_id':d_100['_id']},{'$set':{u'big_cell4':{"POI":venue_count, "cell_ids":cell_ids}}})

    if r % 1000 == 0:
        print ("%d records processed in %2.3f" % (r, time.time()-t0))
        t0 = time.time()

问题是,在mongo shell中使用grid100.count(),我知道有 64141 文档,但是当我运行我的代码时,它最终显示“ 79000条记录在89.857处理“。我认为这意味着处理了79000个文件。我对吗?如果我是对的,那么为什么要处理更多文件以及它们来自何处?

0 个答案:

没有答案