Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

Optimize query performance

A worked example

Multiple answers

A container named catalog stores several million items. It uses an opt-out indexing policy that includes /* and has no composite indexes. The query in the exhibit runs frequently and has a high request charge.

You need to lower the query's request charge by adding composite indexes so that both range filters in the query are optimized. You must add only composite indexes that the query can use.

SELECT * FROM c WHERE c.brand = "Contoso" AND c.price > 2000 AND c.rating >= 4

Which two composite indexes should you add? Each correct answer presents part of the solution.

Choose 2 answers.
Why

Composite indexes can lower the request charge of queries that filter on several properties. Each such index lists equality paths at the front and ends with a range path, and each index can optimize only a single range filter. Because this query has two range filters, it needs two matching indexes: one ending in price and one ending in rating. Every property in each index must be filtered by the query, and the ascending or descending setting has no effect on filtering.

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free