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

Index null values and missing values differently

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Backlog
    • Major - P3
    • Resolution: Unresolved
    • 2.6.0-rc0
    • None
    • Index Maintenance, Querying
    • None
    • Query Optimization

    Description

      A document with a missing value are stored as if they were
      explicitly given the value 'null'. Given:

      X = { b : 1 }                                                                                                                                                                                  
      Y = { a : null, b : 1 }

      X and Y look identical from within a standard index on

      { a : 1 }

      However a sparse index on

      { a : 1 }

      will treat X and Y differently,
      storing Y and not storing X.

      We can safely use an index on $exists queries in the following cases:
      {a:{ $exists:true }} - normal index helps, but we must still fetch
      {a:{ $exists:true }} - sparse index is exact
      {a:{ $exists:false }} - normal index requires a fetch
      {a:{ $exists:false }} - never

      Attachments

        Issue Links

          Activity

            People

              backlog-query-optimization Backlog - Query Optimization
              samantha.ritter@mongodb.com Samantha Ritter (Inactive)
              Votes:
              31 Vote for this issue
              Watchers:
              62 Start watching this issue

              Dates

                Created:
                Updated: