Search code examples
azure-cosmosdbazure-cosmosdb-mongoapi

MongoDB count give not real result


I have a MongoDB on Cosmos Azure account. I have imported a JSON file using a command line and I have used this command:

mongoimport.exe --host xxxx.documents.azure.com:10255 -u xxxxx -p xxxxxxx --ssl --sslAllowInvalidCertificates --db admin --collection machineTest --type json --file "C:\DB\DB_STAGING\MachineTest.json"

and the response into cmd is "imported 5200 documents" but when I run a count query

db.machineTest.count()

the result is 1803 documents

Why the count gives me the not correct result? Thanks


Solution

  • As we know, every operation in cosmos db consumes RUs. If it has not duplicate data, then per my experience, it is because that the size of your entire documents has exceeded the provisioned throughput limit. So, cosmos db returns documents under limitation.

    You could follow below solutions to try to resolve the issue:

    1.You could use continuation toke to query the rest of the documents. Please follow my previous case: Querying large collections in cosmos db

    1. Increasing the reserved throughput for the collection. Of course, it increases your cost.