We're happy to announce that you can now do more within DocumentDB queries. With the latest service deployment, we have made the following increases in the limits for DocumentDB queries.
- Maximum number of AND clauses per query, increased to 20
- Maximum number of OR clauses per query, increased to 10
- Maximum number of JOIN clauses per query, increased to 5
- Maximum number of UDFs per query, increased to 2
- Maximum number of items returned per query page, increased to unlimited
DocumentDB Limits:
If you're familiar with relational database systems, you might be wondering, why does DocumentDB have limits at all? The reason for this is that Azure DocumentDB is built first and foremost for scale, i.e. consistent and repeatable performance at low costs. Every query consumes the same amount of resources, measured as request units or RUs regardless of other operations running on the DocumentDB account, or on other accounts collocated on the same machines. These limits act as a guardrail to ensure that every DocumentDB collection operations within the budget of system resources it has been allocated.
We continuously evaluate use cases, feedback, and monitor usage to raise these limits. We hope that this latest batch of increases unlocks more scenarios for your applications. If you need to operate outside of the new published ranges, then please contact us through support.
With the ability to add 20 AND clauses to a single query, you’ll be able to perform even more powerful queries, as illustrated below.
The Maximum Items Per Page Limit Increase:
If you're currently using DocumentDB, the “maximum number of items per page” limit increase might be a useful knob to you in tuning query performance. The DocumentDB SDKs and REST API have a default page size (FeedOptions.MaxItemCount in .NET) of 100 items per page, and previously supported a maximum of 1000 items. With this change, you can specify a higher value e.g. 10000, or you can specify -1 to denote that queries are not constrained and may return as many results as possible.
Setting the maximum items per page to maximum:
Specifying the maximum items per page (-1) is beneficial in two ways – one, you minimize the number of network round trips required to retrieve results from queries resulting in lower query latency, and two, you minimize the amount of repeated work (RUs) across round trips, resulting in better throughput. Queries will return as many results as can be accommodated by the response size and the throughput capacity of the collection.
Try it now:
Since this is a service side change, you do not need to download a new SDK to take advantage of these new limits. Get started with querying DocumentDB by downloading one of the supported SDKs from here. If you need any help or have questions or feedback, please reach out to us on the developer forums on stack overflow or schedule a 1:1 chat with the DocumentDB engineering team.
Stay up-to-date on the latest DocumentDB news and features by following us on Twitter @DocumentDB.