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

Null queries should be covered by index where possible with current index format

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 4.9.0
    • None
    • None
    • Fully Compatible
    • ALL
    • Query Optimization 2021-03-22

    Description

      Before changing the index format, it is only possible to cover null queries in certain conditions:

      • the index being scanned is not multikey, because indexes alone cannot distinguish between null, missing, undefined, and empty array values
      • the query is either not projecting (as in the case of either legacy or aggregation count) or the query is projecting directly only onto the _id field. This is possible because _id fields are guaranteed to be unique and present, so we can have at most one _id field set to null in the index (meaning we would always get the right value for _id from the index).

      Furthermore, we can optimize counts to use two COUNT_SCANs joined by an OR stage when a single null interval is encountered (instead of just using an INDEX_SCAN with a. filter).

      This branched off of https://jira.mongodb.org/browse/SERVER-18861.

      Attachments

        Issue Links

          Activity

            People

              alya.berciu@mongodb.com Alya Berciu
              alya.berciu@mongodb.com Alya Berciu
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: