Skill 2.1.2

Optimize query performance and Request Units (RUs) consumption by using indexing policies and consistency levels

Key Concepts

By default a container indexes every property, which makes any query possible but adds RU cost and storage to every write. An indexing policy lists included and excluded paths, so properties that are never filtered or sorted can be excluded, which lowers write cost. Composite indexes are required for ORDER BY on several properties and improve queries that filter on one property and sort on another. The indexing mode can be consistent or none; none suits a pure key-value store.

The account's default consistency level is one of Strong, Bounded staleness, Session, Consistent prefix or Eventual. Strong and Bounded staleness reads cost about twice the RUs of the weaker levels, because they read from more replicas. Session, the default, guarantees that a client reads its own writes, which suits most interactive applications. A request can use a weaker level than the account default but never a stronger one.