2016-11-25 78 views
-1

Pymongo對記錄進行排序時發生緩衝區溢出。我想按時間排序只滿足特定位置的記錄1。但我得到了溢出。Pymongo對記錄進行排序時發生緩衝區溢出

>>> 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 

回答

0

要排序對其中索引不存在的字段。 在這種情況下存在的〜32 MB 的限制(見sort operations here) 要解決的問題創建「時間1」作爲索引:

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