I have a simple "Index" object defined as follows:

  "position": 4,
  "value": 345

And I'm trying to figure out the best way to store this object in a mongo database, assuming that:

  • The "position" of each Index is not necessarily unique and does not depend on other Index objects
  • Each user can have a huge number of Index objects associated with it (up to 5000), and the database has a huge number of users (more than 100k)
  • The data is (very) frequently read and updated

What would be the best way to store these objects? The current implementation uses arrays, which is terribly inefficient for users with a low number of Index objects but wide gaps between positions (such as position 5 and position 1623). Should I use JSON objects? Lists?

  • This question belongs to stackoverflow – StackManaged Sep 21 '17 at 12:30
  • @StackManaged I'm not looking for an implementation, I'm looking for an approach – Malfunction Sep 21 '17 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.