Optimize and remediate database performance
Unlock the complete study guide + 25 practice exams totaling 1,500 questions.
Bundled into the existing Building AI Applications with Azure Cosmos DB premium course — no separate purchase.
14-day refund guarantee on one-time purchases and your first subscription charge.
Included in this chapter:
- Measure first: the query troubleshooting loop
- Reading query metrics
- How a filter uses the index
- Indexing policy paths and strategy
- Composite indexes
- Spatial and tuple indexes
- Changing an indexing policy safely
- Index metrics: utilized and potential indexes
- Query Advisor recommendations
- Query rewrites that cut the RU charge
- Cutting latency when the RU charge is acceptable
- The integrated cache
- End-to-end latency versus server-side latency
- Hedging reads across regions
- Client-side bottlenecks in SDK diagnostics
- Azure Monitor alerts for Azure Cosmos DB
- Collecting diagnostic logs in Log Analytics
- KQL investigations over diagnostic logs
- Exam patterns: matching the symptom to the fix
The four evidence sources for Azure Cosmos DB performance work
| Aspect | Per-query instrumentation | SDK diagnostics | Platform metrics | Diagnostic logs |
|---|---|---|---|---|
| How you get it | Query metrics read from the response's Diagnostics (the service's own execution report); index metrics and Query Advisor through query request options | The Diagnostics property on every .NET SDK response and CosmosException | Azure Monitor metrics for the account | A diagnostic setting that routes chosen log categories to a Log Analytics workspace |
| Collected by default? | Query metrics yes; index metrics and Query Advisor default to false | Yes, but your code decides what to log | Yes, automatically | No, not until you create a diagnostic setting |
| Scope | One query, one round trip at a time | One operation, seen from the client | Account, database, container and region over time | Individual requests, queries and partition keys |
| Typical question | Why does this query cost so many RUs? | Where did this slow call spend its time? | Is the workload crossing a threshold? | Which queries, operations or keys consume the RUs? |
Decision tree
Cheat sheet
Unlock with Premium — includes all practice exams and the complete study guide.
Also tested in
References
- https://learn.microsoft.com/en-us/azure/cosmos-db/troubleshoot-query-performance
- https://learn.microsoft.com/en-us/credentials/certifications/resources/study-guides/dp-420
- https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/troubleshoot-dotnet-sdk-slow-request
- https://learn.microsoft.com/en-us/azure/cosmos-db/monitor-server-side-latency
- https://learn.microsoft.com/en-us/azure/cosmos-db/monitor-resource-logs
- https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-types
- https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/query-metrics-performance
- https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/query-metrics
- https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/query/pagination
- https://learn.microsoft.com/en-us/azure/cosmos-db/index-overview
- https://learn.microsoft.com/en-us/azure/cosmos-db/index-policy
- https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/index-metrics
- https://learn.microsoft.com/en-us/azure/advisor/advisor-overview
- https://learn.microsoft.com/en-us/cosmos-db/query/advisor
- https://learn.microsoft.com/en-us/cosmos-db/query/advisor/qa1003
- https://learn.microsoft.com/en-us/cosmos-db/query/getcurrenttimestampstatic
- https://learn.microsoft.com/en-us/azure/cosmos-db/integrated-cache
- https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-configure-integrated-cache
- https://learn.microsoft.com/en-us/azure/cosmos-db/dedicated-gateway
- https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/how-to-dotnet-read-item
- https://learn.microsoft.com/en-us/azure/cosmos-db/transactional-batch
- https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-migrate-from-bulk-executor-library
- https://learn.microsoft.com/en-us/azure/cosmos-db/monitor-reference
- https://learn.microsoft.com/en-us/azure/cosmos-db/performance-tips-dotnet-sdk-v3
- https://learn.microsoft.com/en-us/azure/cosmos-db/per-partition-automatic-failover
- https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/troubleshoot-dotnet-sdk
- https://learn.microsoft.com/en-us/azure/cosmos-db/create-alerts
- https://learn.microsoft.com/en-us/azure/service-health/overview
- https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-alert-on-logical-partition-key-storage-size
- https://learn.microsoft.com/en-us/azure/cosmos-db/monitor-logs-basic-queries
- https://learn.microsoft.com/en-us/azure/cosmos-db/monitor-aggregated-logs
- https://learn.microsoft.com/en-us/azure/azure-monitor/reference/tables/cdbdataplanerequests5m
- https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-configure-firewall