Skip to content

Query Design and Tips

j82w edited this page Feb 4, 2020 · 9 revisions

High level overview of query

Native service interop

  • Provides the ability to parse and optimize the query locally
  • Local query parsing avoids network call which reduces latency
  • Only supported on Windows x64

Two types of queries

Strong recommend to read how Cosmos DB horizontally scales.

Single partition query

  • Does not get impacted by container scaling
  • Can be done by restricting the partition key in the SQL query by using something like a where clause or the partition key can be passed via the request options

Cross partition query

  • SDK visits every physical partition in Cosmos DB and run the query against that physical partition.
    • Depending on the query the SDK may have to aggregate result locally. For example a distinct query would get a distinct list from each partition but has to remove duplicates between partitions.
  • Impacted by container scaling. The larger the container the more physical partitions it will contain.

Clone this wiki locally