Max Candocia
Max Candocia

Reputation: 4385

Why does SELECT count(1) FROM c change values each time I query it in CosmosDB Document Explorer?

I have a database with about 600-700 thousand documents. When I am in the Document Explorer and I execute "SELECT value count(1) FROM c", it returns values ranging from 64,000 to 72,000, seemingly at random. When I execute this using the Python SDK, it returns the actual count I mentioned above. Why is this?

Upvotes: 3

Views: 3174

Answers (1)

Mayur Dhingra
Mayur Dhingra

Reputation: 1577

The count query is limited by the number for RUs allocated to your collection. The response that you would have received will have a continuation token. You have to keep looking for next set of results and keep on adding it, which will give you the final count. For example, I tried a count query on my Cosmos DB, and these were the results

  1. First execution

    [ { "$1": 184554 } ]

  2. Next set of continuation. (By clicking Next button from Azure portal Data Explorer)

    [ { "$1": 181909 } ]

  3. Next set of continuation. (By clicking Next button from Azure portal Data Explorer)

    [ { "$1": 25589 } ]

So, finally the count is 184554 + 181909 + 25589 = 3,92,052

Upvotes: 5

Related Questions