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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Gone away
    • None
    • None
    • Aggregation Framework
    • None
    • 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 :

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: