Practice Exam

Question 39 of 75

Analyze Cosmos DB Query Partition Behavior

You work as a Database Developer for MDFT Pro, a well-known training agency that delivers certification courses to students worldwide. Mark, the Query Optimization Specialist, has asked you to evaluate query patterns for the Student Enrollment Management application. The application uses Azure Cosmos DB with a container partitioned by StudentId. Different queries are used to retrieve enrollment data, and you need to determine which queries are efficiently routed to single partitions versus queries that must scan across all partitions. Understanding query behavior is critical for optimizing performance and minimizing RU consumption.

$resourceGroupName = "StudentResourceGroup"
$accountName = "MDFTProCosmosAccount"
$databaseName = "EnrollmentDatabase"
$containerName = "StudentEnrollments"
$partitionKeyPath = "/StudentId"
$autoscaleMaxThroughput = 5000
New-AzCosmosDBSqlContainer
	-ResourceGroupName $resourceGroupName
	-AccountName $accountName
	-DatabaseName $databaseName
	-Name $containerName
	-PartitionKeyKind Hash
	-PartitionKeyPath $partitionKeyPath
	-AutoscaleMaxThroughput $autoscaleMaxThroughput

You create the following query that targets the container:

SELECT * FROM c WHERE c.UserId = '12345'

Is the following statement about the query true?

Statement: The query is a cross-partition query.

Choose the correct answer from the options below.

Explanations for each answer:

Learn more about Cosmos DB Queries:
Query Cosmos DB Containers
Next Question
Discuss this question on social media: