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

allow indices to optionally cover missing values

    • Type: Icon: New Feature New Feature
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      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:



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


                Error rendering 'slack.nextup.jira:slack-integration-plus'. Please contact your Jira administrators.