2

I have a CosmosDB Collection which I'm querying using the REST API.

I'd like to access the total number of documents which match my query. I know I can do a count, but that means two calls, one for the count and a subsequent one to retrieve the actual records.

I would assume this is not possible in a single call, BUT.. the Data Explorer in Azure Portal seems to manage it, so just wondering if anyone has been able to figure out what calls it makes, to get this:

Showing Results 1 - 10 Retrieved document count 342 Retrieved document size 2868425 bytes Output document count 10

It's the Retrieved Document Count I need - if the portal can do it, there ought to be a way :)

I've tried the JAVA SDK as well as REST but can't see any useful options in there either

1
  • "Retrieved document count" does not have to match real number of documents satisfying the query. It may be higher sometimes. Commented Mar 21, 2019 at 7:32

1 Answer 1

2

As so often is the case in this game, asking a question triggers the answer... so apologies in advance.

The answer is to send the x-ms-documentdb-populatequerymetrics header in the request. The response then gives a whole bunch of useful stuff in x-ms-documentdb-query-metrics.

What I would like to understand still is whether this has any performance impact?

Sign up to request clarification or add additional context in comments.

1 Comment

I'd suggest posting your perf impact question as an actual question. Adding a question to an answer, there's really no way to respond with an "answer."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.