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

$collStats and $indexStats cannot be used on a view with a non-empty pipeline

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Query
    • ALL
    • Hide
      db.runCommand({create: "view", viewOn: "coll", pipeline: [{$match: {}}]});
      db.view.aggregate([{$collStats: {latencyStats: {}}}]);
      // Alternatively db.view.latencyStats();
      

      Will produce this error:

      2016-07-18T13:40:18.285-0400 E QUERY    [thread1] Error: command failed: {
      	"ok" : 0,
      	"errmsg" : "$collStats is only valid as the first stage in a pipeline.",
      	"code" : 2
      } : aggregate failed :
      
      Show
      db.runCommand({create: "view" , viewOn: "coll" , pipeline: [{$match: {}}]}); db.view.aggregate([{$collStats: {latencyStats: {}}}]); // Alternatively db.view.latencyStats(); Will produce this error: 2016-07-18T13:40:18.285-0400 E QUERY [thread1] Error: command failed: { "ok" : 0, "errmsg" : "$collStats is only valid as the first stage in a pipeline." , "code" : 2 } : aggregate failed :

      The $collStats aggregation stage, which will contain relevant statistics about operations run on views, cannot be run on a view if the pipeline is non-empty since it must be the first stage. This also applies to the $indexStats stage, though it's less clear whether we would want $indexStats to run on a view.

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            kevin.albertson@mongodb.com Kevin Albertson
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: