A DBA manages an Azure SQL Database. A stored procedure named dbo.usp_GetOrdersByRegion takes several seconds to run. Its actual execution plan shows a clustered index scan on the Orders table.
The DBA plans to create a nonclustered index to fix the problem. The DBA must be able to show how much the I/O and the duration of the procedure changed, and whether the data access method in the plan changed.
For each of the following statements, select Yes if the statement is true. Otherwise, select No.
| Statement | Yes | No |
|---|---|---|
| Before creating the index, the DBA should run the procedure with SET STATISTICS IO ON and SET STATISTICS TIME ON and record the logical reads and elapsed time as the baseline. The baseline for a slow procedure is captured while confirming that it is slow. This means recording the logical reads and elapsed time from STATISTICS IO and STATISTICS TIME before any change is made. | Correct | |
| Measuring logical reads and elapsed time after the index is created is enough to show how much the I/O and the duration changed. The improvement is shown by comparing the new logical reads and elapsed time with a baseline captured earlier. Measurements taken only after the change have nothing to compare with, so they cannot show how much the values changed. | Correct | |
| After creating the index, comparing the new actual execution plan with the baseline plan lets the DBA check whether an index seek replaced the scan. The source records the initial scan and inspects the actual execution plan again after creating the index. Comparing the plans lets the DBA verify whether the intended change from a scan to a seek occurred. | Correct |
A query-level baseline captures logical reads, elapsed time, and the actual execution plan before the change. After creating the index, the DBA collects these measurements again and compares them with the baseline to assess changes in I/O, duration, and the access method. The comparison checks whether the intended improvements occurred. Measurements collected only after the change provide no reference point.
- Lab: Diagnose a slow query with Copilotgithub.com