What is the best way to store large arrays / lists in mongodb without compromising query performance?
I have a large collection (> 1M records), which consists of lists. Each list has a random length from 0 to> 40 thousand records.
I never change / change list indices - I add only new elements to the end
When accessing data, I should be able to search by index / fields in this list. For example, I could run such queries:
myCollection.find({list: 'awesomeList', index: {$gt: 500}})
myCollection.find({list: 'otherList', name: 'Karl'})
So far I have had several ideas for moving forward:
- Save each list item as a document with an index member
- Save each list item as a document using a special ObjectId to reflect the index
- Store list items in parent in binary tree structure (???)
source
share