Take SORT spilling into account for $sort + $limit

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      InĀ SERVER-113679, we calibrated the cost of spilling to disk for SORT operations. However, we only calibrated for the SORT_SIMPLE and SORT_DEFAULT implementations.

      When using a $sort + $limit, the specific topN algorithm is used, which theoretically could also spill to disk. We initially didn't take this into account because:

      • The cost formula for topN is already complex and hard to extend for the spilling case
      • Usually the $limit values are quite small, and they would have to be really huge (order of 100K) to actually cause spilling

            Assignee:
            Unassigned
            Reporter:
            Max Verbinnen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: