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

Do not generate reversed sort direction plans for time-series

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Integration
    • ALL

      During planning for time-series collections to enable more queries to run with the bounded sort optimization, we pass a traversal preference to the planner. This traversal preference reverses the sort pattern in the original query so we can attempt to plan a backward index scan. Therefore we expect a plan to be generated that has a reversed sort direction when only the backwards index scan satisfies the sort order. This code was introduced in SERVER-64994. However, the function that checks if such a plan can be generated (sortMatchesTraversalPreference) always returns false for compound time-series indexes and sort predicates. I noticed this during a help ticket investigation (fixing this won’t completely solve the customer’s problem). 

      I think this is happening because sortMatchesTraversalPreference will always return false if the field name in the sort pattern doesn’t match the field name in the index pattern. For time-series the index pattern in this function intentionally ignores the meta fields, but the sort pattern does not, so the field names will never match. I didn’t complete a full investigation though. This is blocking plans from using the bounded sort optimization.

      Reproducible is in the comments.

            Assignee:
            Unassigned Unassigned
            Reporter:
            gil.alon@mongodb.com Gil Alon
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: