mongodb-indexes

MongoDB Index on different types

旧时模样 提交于 2019-11-27 05:55:50
问题 We can have { data: "hello" }, { data: 123 } in the same collection and even create a index on it. I'm curious how does mongodb manage the index behind the scene. We can't create single B-tree on different types. Right? However, I did getIndexes to see if another index is created but only one index is created. 回答1: There's no problem having two types in the same index. Each key within the index includes the type. When you query, only objects matching the type you query on will be returned. So

Overflow sort stage buffered data usage exceeds internal limit

帅比萌擦擦* 提交于 2019-11-26 11:44:22
Using the code: all_reviews = db_handle.find().sort('reviewDate', pymongo.ASCENDING) print all_reviews.count() print all_reviews[0] print all_reviews[2000000] The count prints 2043484 , and it prints all_reviews[0] . However when printing all_reviews[2000000] , I get the error: pymongo.errors.OperationFailure: database error: Runner error: Overflow sort stage buffered data usage of 33554495 bytes exceeds internal limit of 33554432 bytes How do I handle this? You're running into the 32MB limit on an in-memory sort: https://docs.mongodb.com/manual/reference/limits/#Sort-Operations Add an index