1

I am working with Azure DocumentDB. I am looking at the ExecuteNextAsync operation. What I am seeing is the the ExecuteNextAsync returns no resluts. I am using examples I have found on line and don't generate any results. If I call an enumeration operation on the initial query results are returned. Is there an example showing the complete configuration for using ExecuteNextAsync?

Update To be more explicit I am not actually getting any results. The call seems to just run and no error is generated.

Playing around with the collection defintion, I found that when I set the collection size to 250GB that this occurred. I tested with the collection to 10GB and it did work, for a while. Latest testing shows that the operation is now hanging again.

I have two collections generated. The first collection appears to work properly. The second one appears to fail on this operation.

Community
  • 1
  • 1
Peter
  • 173
  • 12

1 Answers1

1

Individual calls to ExecuteNextAsync may return 0 results, but when you run the query to completion by calling it until HasMoreResults is false, you will always get the complete results.

Almost always, a single call to ExecuteNextAsync will return results, but you may get 0 results commonly due to two reasons:

  • If the query is a scan, then DocumentDB will make partial progress based on available throughput. Here no results are returned, but a new continuation token based on the latest progress is returned to resume execution.
  • If it's a cross-partition query, then each call executes against a single partition. In this case, the call will return no results if that partition has no documents that match the query.

If you want queries to deterministically return results, you must use SELECT TOP vs. using the continuation token/ExecuteNextAsync as a mechanism for paging. You can also read query results in parallel across multiple partitions by changing FeedOptions.MaxDegreeOfParallelism to -1.

Aravind Krishna R.
  • 7,885
  • 27
  • 37
  • From what I understand the HasMoreResults relate to the identification that the query has more available results based on a paging strategy. And that HasMoreResults is meant for paging through the results. And not to make sure you get results. I don't believe I can use this property in my scenario. I do having paging active but is based on using the RequestContinuation token, on a subsequent call. The query is a simple select on a collection. – Peter Apr 26 '17 at 19:37
  • Also -- I am performing a count on the same query (that returns no records) and the count comes back greater than zero - so an aggregation appears to work. – Peter Apr 26 '17 at 19:44