NoSQL database learning-Restrictions on MongoDB's groupby if you use the group command, you may encounter the following two errors: www.2cto. coma .) command: db. flogsamplelog. group ({cond: {datetimes: 20111027}, key: {pid: 1}, initial: {count: 0}, reduce: function (doc, prev) {if (doc. pidprev. pid) prev
NoSQL database learning-MongoDB group by restrictions if you use the group command, you may encounter the following two errors: www.2cto.com .) command: db. flogsamplelog. group ({cond: {datetimes: 20111027}, key: {pid: 1}, initial: {count: 0}, reduce: function (doc, prev) {if (doc. pid = prev. pid) prev
NoSQL database learning-MongoDB group by restrictions
If you use the group command, you may encounter the following two errors:
Www.2cto.com
A .) command: db. flogsamplelog. group ({cond: {datetimes ": 20111027}, key: {" pid ":" 1 "}, initial: {" count ": 0}, reduce: function (doc, prev) {if (doc. pid = prev. pid) prev. count ++ ;}})
Error:
Mon Oct 31 12: 00: 00 uncaught exception: group command failed :{
"Errmsg": "exception: group () can't handle more than 10000 unique keys ",
"Code": 10043,
"OK": 0
} Directly access the shard server port
B .) command: db. flogsamplelog. group ({cond: {"pid": 322963713, "datetimes": 20111027}, key: {"worktype": "1"}, initial: {"count ": 0}, reduce: function (doc, prev) {if (doc. worktype = prev. worktype) prev. count ++ ;}})
Error:
Mon Oct 31 12:00:09 uncaught exception: group command failed: {"OK": 0, "errmsg": "can't do command: group on sharded collection"} directly access the port of the route server
Second, we can also find such a statement in the mongodb authoritative guide:
The price of using MapReduce is speed: group is not special speedy,
MapReduce is slower and is not supposed to be used in "real time." You run
MapReduce as a background job, it creates a collection of results, and then
You can query that collection in real time.
After tests, it is found that the efficiency of group by has not been substantially improved after the index is created.
The fields and table definitions involved in specific commands are not perfunctory here.