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

aggregation can sort using index to speed up group of an indexed field

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 2.4.7, 2.5.3
    • Fix Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible

      Description

      If "$group" is grouping on an indexed field F and if all the functions are not dependent on the rest of the document (such as $sum:1 aka count) huge improvement can be made in performance by adding '{$sort:{F:1'}} before the '{$group}'

      Tested on large collection (TPCH orders denormalized with lineitems inside) about 1.5 million documents aggregating by order date (2600 different dates) all after warming the data first:

      Without sort: 18-19 seconds
      With sort: 2.5-2.6 seconds

      On really small datasets I still see at least 25%-33% improvement with $sort so if we can do that "automatically" that would help performance.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              asya Asya Kamsky
              Participants:
              Votes:
              6 Vote for this issue
              Watchers:
              15 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: