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

allow indices to optionally cover missing values

    XMLWordPrintable

Details

    • New Feature
    • Status: Closed
    • Minor - P4
    • Resolution: Duplicate
    • None
    • None
    • None

    Description

      I often need to run queries of the form {a: {$ne:null}}, i.e. find documents in which the field "a" is not missing and not equal to null. As I understand it, an index on "a" will not cover this query because the index will not include documents where "a" is missing.

      In these cases I find myself forced to always include a value for "a". This isn't hard to do - generally there's always some value I can reserve for this purpose (often "null" of course, but sometimes another value if "null" doesn't mean the same thing as a missing value).

      It seems to me that mongo could do this for me transparently (by reserving a value to indicate "missing" and including those documents in the index). I completely understand that minimizing index size is important, and this wouldn't be appropriate in many contexts, and certainly not as a default. Nevertheless, this comes up over and over again (I've been running an expansive production environment on mongo for many years). So I think it would make an incredibly useful option when creating an index.

      Apologies if I'm missing something about why this isn't feasible (or perhaps feasible but not simple) to implement, or why it's not a good idea. I tried to cover this in a bit more detail on stack overflow before submitting this request:

      https://stackoverflow.com/questions/63003917

       

      Attachments

        Issue Links

          Activity

            People

              asya.kamsky@mongodb.com Asya Kamsky
              jeremy@nonagontech.com Jeremy Todd
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: