Courseiva

DP-900 Practice Question: Identify considerations for relational data on Azure

A company runs an e-commerce application on Azure SQL Database. The database has a table named Orders with columns: OrderID (int, primary key), CustomerID (int), OrderDate (datetime), TotalAmount (decimal). The application frequently runs the following query: SELECT * FROM Orders WHERE CustomerID = 12345 AND OrderDate BETWEEN '2025-01-01' AND '2025-01-31' ORDER BY OrderDate DESC. The table contains 10 million rows. Which index would best optimize this query?

⚠ Common exam trap

It's easy for candidates to think a single-column index on the most selective column (OrderDate) is sufficient, but they overlook that the query's equality filter on CustomerID must be the leading key column to enable an efficient seek, and that including the SELECT column avoids key lookups.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

A nonclustered index on (CustomerID, OrderDate DESC) including TotalAmount as included column.

The query filters on both CustomerID and OrderDate, so a composite nonclustered index on (CustomerID, OrderDate DESC) allows SQL Server to perform an index seek on CustomerID and then an ordered range scan on OrderDate, avoiding a sort operation. Including TotalAmount as an included column makes the index covering, so the query can be satisfied entirely from the index without key lookups to the clustered index.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • A nonclustered index on OrderDate only.

    Why it's wrong here

    An index on OrderDate alone would help date range scans, but still requires filtering on CustomerID, leading to key lookups or residual predicates. It is not as efficient as a composite index that includes CustomerID.

  • A nonclustered index on (CustomerID, OrderDate DESC) including TotalAmount as included column.

    Why this is correct

    This composite index is optimal because the leading key column CustomerID enables a precise equality seek to exactly the rows for the specified customer. The OrderDate DESC key column then provides both an efficient range scan for the date condition and returns rows already in the required ORDER BY OrderDate DESC order, eliminating a sort operator. Adding TotalAmount as an included column makes the index fully covering: all columns referenced in the SELECT, WHERE, and ORDER BY are present in the index, so SQL Server can satisfy the query entirely from the nonclustered index without costly key lookups into the clustered index or heap.

  • A clustered index on (OrderDate, CustomerID).

    Why it's wrong here

    A clustered index on (OrderDate, CustomerID) forces a scan of all rows for the matching CustomerID because the leading key is OrderDate, not the equality filter column. It is tempting because ordering by OrderDate DESC is already satisfied by the index order, but without CustomerID leading, the query cannot seek directly to the customer’s rows. This index would be correct if the query filtered primarily on a date range without an equality predicate on CustomerID.

  • A nonclustered index on (OrderDate DESC) only.

    Why it's wrong here

    An index on OrderDate DESC alone cannot support a seek on CustomerID because CustomerID is not the leading key column. When the query filters on CustomerID with equality, SQL Server would have to either scan the entire nonclustered index (or clustered index) and check each row's CustomerID, or perform key lookups for every matching OrderDate range row, which is extremely inefficient for a large orders table. While the index does preserve OrderDate DESC order, that benefit is largely irrelevant because the CustomerID filter prevents a direct seek to the relevant rows, and the missing TotalAmount still forces additional key lookups to retrieve that column. Effectively, this index is no more useful for this query than a clustered index scan with a sort, making it a poor choice compared to the composite covering index.

About these practice questions

Courseiva writes every DP-900 question from scratch — 820 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This DP-900 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DP-900 exam.