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

Consider checking whether the array passed to $in is already sorted before calling std::sort

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.0.1, 4.1.1
    • Affects Version/s: None
    • Component/s: Querying
    • None
    • Fully Compatible
    • v4.0
    • Query 2018-07-02, Query 2018-07-16
    • 0

      As part of SERVER-35693, parsing a $in query will always sort the array argument before constructing a boost::flat_set. This greatly benefits the case where the number of elements is very large (>10k) and is unsorted, however as a side effect it hurts performance when the array is already sorted.

      One option would be to add an optimization for the sorted case by checking std::is_sorted before sorting the array.

            Assignee:
            nicholas.zolnierz@mongodb.com Nicholas Zolnierz
            Reporter:
            nicholas.zolnierz@mongodb.com Nicholas Zolnierz
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: