Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-12614

Proposal for enhancing MongoDB indexes

    • Query

      One of the things we learn from "Index Cardinality" video [M101J: MongoDB for Java Developers] is that when a document with multikey index get moved, all of his indexes must be updated as well, which incur a significant overhead.

      I've thought would it be possible to somehow bypass this constraint. The obvious solution is to add another level of indirection (this is a famous pattern for solving computer science problems ) and instead of referencing the document directly from the index we create an entity for each document that reference that document and get the indexes to reference that entity, and now when we move the document we only have to modify that entity only (the entity will never move because its BSON shape will always be the same). The problem with this solution of course is that of trading space for performance (indexes also suffer from this problem).

      But all hope is not lost; in MongoDB all documents have an immutable _id field which is automatically indexed. Given all this we know that if a document is ever moved its associated _id index will also be updated, so why not just make all the other indexes references the corresponding _id index of the document?

      Given this solution the only index that will be ever be updated when a document moves is the _id index.

      I want to know if this solution could possibly be implemented in MongoDB or are there some hidden gotchas to it that would make it impractical?

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            chekkal chekkal
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: