Designing and Implementing Cloud-Native Applications Using Microsoft Azure Cosmos DB — Question 51

You have an Azure Cosmos DB for NoSQL account that contains a database named DB1.

Users run the following query against DB1.

SELECT *

FROM c -
WHERE c.bikeParts = "Frame, Chain, Peddles"

ORDER BY c.bikeParts ASC -

You add an index to the recordset.

You need to change the ORDER BY syntax of the query to optimize the use of the index. The solution must NOT change the result set.

Which syntax should you use?

Answer options

Correct answer: D

Explanation

The correct answer is D because it allows for the efficient use of the index by first ordering by c.bikeParts in descending order and then by c._ts in ascending order. This maintains the same result set while optimizing the query execution. The other options either change the order of the results or do not utilize the index effectively.