In this lesson, you will learn how to use the Database Engine Tuning Advisor (DTA) safely and professionally.
DTA can analyze a workload (queries) and recommend physical design changes such as indexes, indexed views,
and partitioning (depending on edition/features). However, DTA is not a magic button. It can recommend indexes that:
increase storage, slow down inserts/updates, and create maintenance problems.
Big Idea: DTA is a recommendation engine, not an “auto-fix tool.”
You must evaluate suggestions using cost/benefit logic: read performance improvements versus write overhead, storage growth,
and operational complexity. The DBA’s job is to choose what to implement, what to reject, and how to validate results.
You will learn:
90–150 minutes (lecture + demo + evaluation lab)
DTA analyzes a workload and tries to recommend changes that reduce query cost. It simulates design alternatives
(primarily indexes) and estimates which options would improve performance.
Key teaching point: DTA can recommend a design that makes reads faster while making writes significantly slower.
A DBA must balance both.
DTA is only as good as the workload you feed it. The number one reason DTA fails is that the workload is incomplete or unrealistic.
You want DTA to see the queries that matter most in real life.
Key teaching point: If you feed DTA the wrong workload, DTA will “optimize” you into a worse system.
The DBA owns workload selection.
DTA recommendations usually fall into categories. You must understand the cost of each.
Key teaching point: DTA measures query cost reduction, but it does not fully model
your operational reality (write rates, maintenance windows, storage limits, uptime requirements).
When DTA recommends an index, you must treat it as a hypothesis:
“If we add this index, this workload will improve.” Your job is to test that hypothesis safely.
Key teaching point: Your best DTA strategy is “implement the fewest indexes that deliver the largest benefit.”
A small number of well-designed indexes beats hundreds of questionable indexes.
DBA standard: If you cannot prove improvement with before/after metrics, you are not tuning—you are guessing.
Use these scripts to inspect existing indexes and avoid creating duplicates or unnecessary bloat.
/* Replace schema/table */
DECLARE @schema SYSNAME = N'dbo';
DECLARE @table SYSNAME = N'YourTable';
SELECT
i.name AS index_name,
i.type_desc,
i.is_unique,
i.is_primary_key,
STUFF((
SELECT N', ' + c.name
FROM sys.index_columns ic
JOIN sys.columns c
ON c.object_id = ic.object_id
AND c.column_id = ic.column_id
WHERE ic.object_id = i.object_id
AND ic.index_id = i.index_id
AND ic.is_included_column = 0
ORDER BY ic.key_ordinal
FOR XML PATH(''), TYPE).value('.','nvarchar(max)'),
1, 2, N'') AS key_columns,
STUFF((
SELECT N', ' + c.name
FROM sys.index_columns ic
JOIN sys.columns c
ON c.object_id = ic.object_id
AND c.column_id = ic.column_id
WHERE ic.object_id = i.object_id
AND ic.index_id = i.index_id
AND ic.is_included_column = 1
ORDER BY ic.index_column_id
FOR XML PATH(''), TYPE).value('.','nvarchar(max)'),
1, 2, N'') AS included_columns
FROM sys.indexes i
WHERE i.object_id = OBJECT_ID(QUOTENAME(@schema) + N'.' + QUOTENAME(@table))
AND i.index_id > 0
ORDER BY i.index_id;
How to interpret: If DTA recommends an index with the same key columns (or a near-duplicate),
you may already have an index that can be adjusted instead of adding a new one.
/* Index usage (since last restart) - interpret with caution */
SELECT
OBJECT_SCHEMA_NAME(i.object_id) AS schema_name,
OBJECT_NAME(i.object_id) AS table_name,
i.name AS index_name,
u.user_seeks,
u.user_scans,
u.user_lookups,
u.user_updates
FROM sys.indexes i
LEFT JOIN sys.dm_db_index_usage_stats u
ON u.object_id = i.object_id
AND u.index_id = i.index_id
AND u.database_id = DB_ID()
WHERE i.index_id > 0
ORDER BY (ISNULL(u.user_seeks,0) + ISNULL(u.user_scans,0) + ISNULL(u.user_lookups,0)) ASC,
ISNULL(u.user_updates,0) DESC;
How to interpret: Many “extra” indexes add write overhead. But do not drop indexes just because they look unused—
usage stats reset after restart and some indexes support infrequent but critical workloads.
Students will run DTA against a small workload (lab queries), then select only the best recommendation(s) and justify them.
Prompt:
“DTA recommends 15 new indexes for one workload capture. What are the top 5 questions you would ask before implementing any of them?
How would you decide which 1–2 indexes are worth it?”
In the next lesson, we will cover SQL Server High Availability and Disaster Recovery.
You will learn the difference between HA and DR, common architectures (Failover Clustering, Always On availability groups, backups/log shipping),
and how performance tuning considerations change in high-availability environments.
Not a member yet? Register now
Are you a member? Login now