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

Make IndexBounds for wildcard multikey path query respect the wildcard field's ordering

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 7.0.0-rc0
    • None
    • None
    • Query Optimization
    • Fully Compatible
    • QO 2023-02-20

    Description

      See comments for repro steps.

      ---- Investigation results ----
      (This failure happens especially when the wildcard field is in descending order.)

      Root cause: IndexBounds generated to query a wildcard index’s multikey paths does not respect the ordering of the wildcard field.

      There is a false assumption that the multikey path keys are stored in ascending order always, but it actually depends on the ordering of the wildcard field. Here's some related code, we can assure "$_path" field is always in ascending order, but when we generate keys for multikey paths, the ordering of the multikey path actually aligns with the wildcard field.

      For example,

      Keys generated for wildcard index: 

      {"$_path": 1, "$**": -1}

      with Ordering

      {“”: 1, “”: -1}

      :

      {"": 1, "": "a"}
      {"": 1, "": "a.c.d"}
      {"": 1, "": "e"}
      {"": "a.b", "": 1}
      {"": "a.b", "": 2}
      {"": "a.c", "": 1}
      

      The first three are multikey-path index keys, the second column in descending order is for the multi key paths. While in the last three keys indexing documents, the first column in ascending order represents the path.

      Attachments

        Activity

          People

            ruoxin.xu@mongodb.com Ruoxin Xu
            alya.berciu@mongodb.com Alya Berciu
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: