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

performance problem with $limit in aggregate query

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.2.6
    • Component/s: Aggregation Framework
    • Labels:
      None
    • ALL
    • Hide

      For example, create a query where the first stage is a $match that only finds 6 docs. Second stage is a $sort on an indexed field. Third stage is a $limit=10.

      The total document collection size is about 6GB.

      Show
      For example, create a query where the first stage is a $match that only finds 6 docs. Second stage is a $sort on an indexed field. Third stage is a $limit=10. The total document collection size is about 6GB.

      We seem to have a performance problem with $limit in aggregate queries. The query is very very slow (half a minute) - when the number of docs passed into the limit step are less than the limit size.

      The query is instantaneous when there are lots of docs returned from stage 1. However, when there are only a few, the aggregate query is very very slow.

      Expected behavior: aggregate performance of $limit should be equivalent to a standard query's use of limit.

            Assignee:
            kelsey.schubert@mongodb.com Kelsey Schubert
            Reporter:
            dan@prattle.co Dan Salmo
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: