Practice Exam

Question 38 of 75

Identify Cosmos DB Cross-Partition Query

You work as a Database Developer for MDFT Pro, a well-known training agency that delivers certification courses to students worldwide. Claire, the Application Performance Lead, has asked you to analyze query performance for the Student Enrollment Management application that uses Azure Cosmos DB as its data store. You created a container to store student enrollment records using the PowerShell script below, which partitions data by StudentId. During performance testing, you notice varying query costs and want to understand whether specific queries are optimized as in-partition queries (which access only one partition) or if they’re cross-partition queries (which scan multiple partitions and consume more RUs).

$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.StudentId > '12345'

Is the following statement about the query true?

Statement: The query is an in-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: