MongoDB count results in incorrect number (MongoDB count a pit)

Source: Internet
Author: User

In a MongoDB cluster, if exists orphaned documents and chunk migration, the count query may result in an incorrect query result, such as I was stepping on the pit, first not talking, see the result:

Skip can only get to 54631, and count found out 77,396 data, this is the pit, the same query conditions, not the same results, in order to avoid this result, you can use the aggregate query,

As shown, the inside is a pit.

For more information on the count of MongoDB, see official website: https://docs.mongodb.com/manual/reference/command/count/

MongoDB count results in incorrect number (MongoDB count a pit)

Related Article

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.