DP-420 · Question #185
You have an Azure subscription. The subscription contains an Azure Cosmos DB for NoSQL account named account1 that hosts a container named Devices. Devices has a partition key named type. You plan…
The correct answer is A. as an in-partition query. In Azure Cosmos DB, queries are optimized based on the partition key. Since the container Devices has a partition key named type, and the query includes the condition d.type = 'car', the query can be executed within a single partition (an in-partition query). This is because…
Question
You have an Azure subscription. The subscription contains an Azure Cosmos DB for NoSQL account named account1 that hosts a container named Devices. Devices has a partition key named type. You plan to execute the following query. SELECT d.deviceName FROM d WHERE d.deviceId = 'ABC102' AND d.type = 'car' AND d.importanceId = 4 You are evaluating the resource utilization of the query. How will the query be executed?
Options
- Aas an in-partition query
- Bas a parallel cross-partition query
- Cas a cross-partition query
How the community answered
(49 responses)- A88% (43)
- B4% (2)
- C8% (4)
Explanation
In Azure Cosmos DB, queries are optimized based on the partition key. Since the container Devices has a partition key named type, and the query includes the condition d.type = 'car', the query can be executed within a single partition (an in-partition query). This is because the type field is specified, which allows Cosmos DB to directly target the partition containing the documents with type = 'car'. Given that the query is restricted to a specific partition (i.e., type = 'car'), Cosmos DB does not need to scan across all partitions. The query will be executed efficiently within the specified partition, even though it includes other conditions (like d.deviceId = 'ABC102' and d.importanceId = 4), because those are additional filters within the targeted partition.
Topics
Community Discussion
No community discussion yet for this question.