当我通过Pymongo对记录进行排序时,缓冲区溢出

时间:2016-11-25 22:10:35

标签: python mongodb pymongo

当我通过Pymongo对记录进行排序时,缓冲区溢出。我想按时间排序记录只满足某个位置1。但是我得到了溢出。

>>> records = db['LOG'].find({"location":"172.27.112.18"}).sort('time1', 1)
>>> for i in records:
...     nill.append(i)
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/pymongo/cursor.py", line 1090, in next
    if len(self.__data) or self._refresh():
  File "/usr/lib64/python2.7/site-packages/pymongo/cursor.py", line 1012, in _refresh
    self.__read_concern))
  File "/usr/lib64/python2.7/site-packages/pymongo/cursor.py", line 903, in __send_message
    codec_options=self.__codec_options)
  File "/usr/lib64/python2.7/site-packages/pymongo/helpers.py", line 137, in _unpack_response
    error_object)
pymongo.errors.OperationFailure: database error: Plan executor error during find: Overflow sort stage buffered data usage of 33554525 bytes exceeds internal limit of 33554432 bytes

1 个答案:

答案 0 :(得分:0)

您正在对不存在索引的字段进行排序。 在这种情况下,存在~32 MB的限制 (见sort operations here) 要解决此问题,请在'time1'上创建索引:

db.LOG.create_index([('time1', 1)])