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

Not needed SORT_KEY_GENERATOR in aggregation explain output

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.6.3
    • Component/s: Aggregation Framework
    • None
    • ALL
    • Hide
      sh.enableSharding("test")
      
      sh.shardCollection("test.sharded",{a:1})
      for(i=0;i<100;i++){db.sharded.insert({a:i})}
      for(i=0;i<10;i++){sh.splitFind("test.sharded",{a:i})}
      // Wait for the balancer to distirbute the chunk
      
      // No sort stage
      db.sharded.explain().find().sort({a:1})
      
      // SORT_KEY_GENERATOR stage
      db.sharded.explain().aggregate([{$sort:{a:1}}])
      
      // SORT_KEY_GENERATOR is not shown if the aggregation impacts only one shard
      db.sharded.explain().aggregate([{$match:{a:{$gt:50}}},{$sort:{a:1}}] )
      
      Show
      sh.enableSharding( "test" ) sh.shardCollection( "test.sharded" ,{a:1}) for (i=0;i<100;i++){db.sharded.insert({a:i})} for (i=0;i<10;i++){sh.splitFind( "test.sharded" ,{a:i})} // Wait for the balancer to distirbute the chunk // No sort stage db.sharded.explain().find().sort({a:1}) // SORT_KEY_GENERATOR stage db.sharded.explain().aggregate([{$sort:{a:1}}]) // SORT_KEY_GENERATOR is not shown if the aggregation impacts only one shard db.sharded.explain().aggregate([{$match:{a:{$gt:50}}},{$sort:{a:1}}] )
    • Query 2018-05-07

      In 3.6 the aggregation explain output shows a SORT_KEY_GENERATOR stage even when it is not needed.

            Assignee:
            charlie.swanson@mongodb.com Charlie Swanson
            Reporter:
            renato.riccio@mongodb.com Renato Riccio
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: