1

I've got 1 million entries in a collection. After my query I receive 500 entries for user_id = X. I am looking now for one entry of this subset and 5 before and 5 after this item. What would be best strategy?

For the beginning I just select the 500 items: db.items.find({"user_id": 1}).limit(500);

I could now loop through 500 items to find my current item but it seems to me very inconvenient. Is there maybe a better way?

hazelnut
  • 157
  • 9

0 Answers0