[SERVER-26535] result of collection count function does not equals with result of aggregate count function Created: 09/Oct/16 Updated: 03/Apr/23 Resolved: 11/Oct/16 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | jacky chen | Assignee: | Kelsey Schubert |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
db.version() = 3.2.8 { , , |
||
| Operating System: | ALL | ||||||||||
| Steps To Reproduce: | db.collection.count() shows 5
|
||||||||||
| Participants: |
| Description |
|
evn description: but we got two different results via pure count function and aggregate count function according to below docs. I'm not sure whether this is a bug or my command is wrong. |
| Comments |
| Comment by Kelsey Schubert [ 11/Oct/16 ] | |||||||||||||||||||||
|
Hi update0412, I'm glad that running validate resolved this issue. Following an unclean shutdown, it is expected that these counts may be off by some amount. The validate command steps through the documents and indexes and performs a number of checks on them. As part of this process, the recordstore count is updated. Feel free to take a look at the relevant source code for additional information: Please note that SERVER project is for reporting bugs or feature suggestions for the MongoDB server. For MongoDB-related support discussion please post on the mongodb-users group or Stack Overflow with the mongodb tag. A question like this involving more discussion would be best posted on the mongodb-users group. Kind regards, | |||||||||||||||||||||
| Comment by jacky chen [ 11/Oct/16 ] | |||||||||||||||||||||
|
Hi Thomas, Thanks for your quick reply. I try to execute db.system.users.validate(true) and then count() returns correct value. below is validate print
Could you share more detials about the validate functionality ? thanks a lot. B.R. | |||||||||||||||||||||
| Comment by Kelsey Schubert [ 10/Oct/16 ] | |||||||||||||||||||||
|
Hi update0412, Thank you for reporting this behavior. Would you please provide the output of db.system.users.validate()? And confirm if the issue is resolved? Please be aware that validate is resource intensive and may have an impact on the performance of your MongoDB instance. Thank you, | |||||||||||||||||||||
| Comment by jacky chen [ 09/Oct/16 ] | |||||||||||||||||||||
|
collection is admin.system.users |