NoSQL database learning-Restrictions on MongoDB's groupby

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.