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

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.9.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Fully Compatible
    • ALL
    • Query Optimization 2021-03-22

      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.

            alya.berciu@mongodb.com Alya Berciu
            alya.berciu@mongodb.com Alya Berciu
            0 Vote for this issue
            6 Start watching this issue