Question 706 of 820
Create a Non-Clustered Composite Index for Filter and Sort Queries in Azure SQL Database
A company uses Azure SQL Database for an inventory management system. The Inventory table has millions of rows. Queries frequently filter on WarehouseID and then sort by LastUpdatedDate. The table currently has a clustered index on InventoryID (primary key). Which action will most improve query performance for these frequent filters?
Quick Answer
The answer is to create a non-clustered composite index on (WarehouseID, LastUpdatedDate) with the Quantity column included. This works because a composite index on both columns allows Azure SQL Database to perform composite index filtering sorting in a single index seek, locating rows by WarehouseID while already returning them in the correct sort order of LastUpdatedDate without a separate sort operation. Including Quantity as a non-key column eliminates expensive key lookups to the clustered index, directly addressing the query’s need for that column. On the DP-900 exam, this scenario tests your understanding of covering indexes and the difference between key columns (used for filtering and sorting) and included columns (added to avoid lookups). A common trap is choosing a single-column index on LastUpdatedDate, which ignores the filter, or changing the clustered index, which would break uniqueness and cause fragmentation. Memory tip: “Composite for filter and sort, include the rest to avoid a key-lookup quest.”
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
✓
Create a non-clustered index on (WarehouseID, LastUpdatedDate) INCLUDE (Quantity)
A non-clustered index on (WarehouseID, LastUpdatedDate) allows the database engine to efficiently locate rows matching a specific WarehouseID and return them already sorted by LastUpdatedDate without accessing the clustered index (or with minimal lookup). Including the Quantity column as a non-key included column avoids key lookups for that column, further improving performance. Changing the clustered index to WarehouseID could cause fragmentation and is not ideal for uniqueness. A single-column index on LastUpdatedDate does not support the filter on WarehouseID. Partitioning by InventoryID does not help this query pattern.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Create a non-clustered index on (WarehouseID, LastUpdatedDate) INCLUDE (Quantity)
Why this is correct
This composite index covers the filter and sort conditions. Including Quantity as an included column makes the index covering for this query, avoiding expensive key lookups.
- ✗
Add a clustered index on WarehouseID
Why it's wrong here
Changing the clustered index to WarehouseID may cause row movement and fragmentation, as WarehouseID is likely not unique. A clustered index should ideally be unique and stable.
- ✗
Create a non-clustered index on LastUpdatedDate only
Why it's wrong here
This index helps sorting by LastUpdatedDate, but does not support the filter on WarehouseID. The database would still need to scan or perform lookups for the specific WarehouseID.
- ✗
Partition the table by InventoryID
Why it's wrong here
Partitioning by InventoryID does not align with the query pattern. Queries filtering on WarehouseID would still span multiple partitions, providing no performance benefit.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on DP-900
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A company uses Azure SQL Database to store a large table of sales transactions with columns: TransactionID (primary key), CustomerID, ProductID, SaleDate, Amount. Queries frequently filter by both CustomerID and SaleDate to retrieve sales for a specific customer over a date range. Which indexing strategy will most improve query performance?
medium- A.Create a clustered index on SaleDate
- B.Create a nonclustered index on CustomerID and include SaleDate
- ✓ C.Create a nonclustered index on (CustomerID, SaleDate)
- D.Create a nonclustered index on (SaleDate, CustomerID)
Why C: Creating a nonclustered index on (CustomerID, SaleDate) as a composite index directly supports the query predicate that filters by both CustomerID and SaleDate. The index is ordered by CustomerID first, enabling efficient seeks for a specific customer, and then by SaleDate within each customer, allowing the query engine to perform a range scan for the date range without scanning the entire table or sorting. This index is a covering index for this query, as it contains all columns needed for the filter, avoiding key lookups.
Last reviewed: May 17, 2026
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.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.