[SERVER-9126] Cannot get query plan or status for distinct() routed through mongos Created: 25/Mar/13 Updated: 05/Aug/15 Resolved: 05/Aug/15 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 2.2.3, 2.4.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Jay Wineinger | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Operating System: | ALL | ||||||||||||||||
| Steps To Reproduce: | Issue a distinct command using runCommand. Observe the output does not have a query plan nor status. |
||||||||||||||||
| Participants: | |||||||||||||||||
| Description |
|
I am unable to find any way to get the query plan and stats for a distinct query in mongo shell. explain() is not valid to chain onto distinct(). The 2.2 documentation says (http://docs.mongodb.org/v2.2/reference/command/distinct/) says that "the command returns a document that contains an array of the distinct values as well as the query plan and status." mongos> db.actions.distinct("a", {...}).explain()Mon Mar 25 14:24:35 TypeError: db.actions.distinct("a", {...} ).explain is not a function (shell):1 mongos> db.runCommand({distinct:'actions', key:"a", query:{...}}) { "values" : [ "love" ], "ok" : 1 } |
| Comments |
| Comment by Qingyang Chen [ 05/Aug/15 ] | |||||||||||||||||||||||||||||||||||||
|
Closing as duplicate of You can now do db.<collection>.explain(...).distinct(...). An example of the output:
| |||||||||||||||||||||||||||||||||||||
| Comment by Thomas Rueckstiess [ 26/Mar/13 ] | |||||||||||||||||||||||||||||||||||||
|
I can confirm that the distinct command will only return the "stats" field, when the collection is not sharded. Before sharding the collection:
After sharding the collection:
Need to confirm if this is by choice (or due to certain implementation limitations) or if this is a bug. |