Online Class • Next Lesson
Indexing is the most powerful and most misunderstood performance tool in SQL Server.
In this lesson, you will learn what indexes really are, how SQL Server uses them (seek vs scan),
how to design indexes that speed up reads without destroying writes, and how to avoid the most common
index mistakes that cause bloat, fragmentation, and slow insert/update performance.
An index is a data structure that helps SQL Server find rows faster, reduce page reads, and improve query response time.
But indexes are not “free.” Every index must be maintained on writes (INSERT/UPDATE/DELETE), and too many indexes can slow down
the system. In performance tuning, the goal is not “more indexes”—the goal is the right indexes.
Indexing is about controlling how many pages SQL Server must read to answer a question.
Great indexes reduce logical reads, improve seek access, and avoid expensive lookups and sorts.
Bad indexes create bloat, slow writes, and still don’t fix slow queries.
75–120 minutes (concepts + demo + index design lab)
SQL Server performance is often a “reading problem.” Slow queries usually read too many pages.
Indexes reduce the pages SQL Server must touch, which reduces CPU and I/O and improves concurrency.
Key teaching point: A scan is not always “bad,” and a seek is not always “good.”
The goal is not to force seeks—it’s to minimize total work and reads for the real workload.
In SQL Server, every table is either a heap (no clustered index) or a clustered table
(has a clustered index). This choice affects how data is physically organized and how nonclustered indexes find rows.
Key teaching point: The clustered index is not “just another index.”
It defines how the entire table is organized and affects seek efficiency, range queries, and lookup cost.
A nonclustered index is a separate structure that stores the index key and a pointer back to the base table (heap or clustered).
If the query needs columns not stored in the index, SQL Server performs a lookup to fetch missing columns.
Too many lookups can become extremely expensive under concurrency.
A covering index is an index that contains all columns needed by the query (filter + join + select output),
allowing SQL Server to return results without extra lookups.
Covering indexes often reduce reads dramatically and can stabilize performance.
Index design is not random. SQL Server can only “seek” effectively when the index key order supports the query predicates.
The order of columns in a composite index matters because SQL Server typically navigates using the leading key columns first.
Key teaching point: The “best” index is the one that improves the real workload and costs the least to maintain.
Good tuning balances read speed and write cost.
Index performance depends on more than the index definition.
Statistics influence plan choices. Fragmentation can increase I/O for some workloads. Maintenance must be based on evidence,
not habit. In modern SQL Server environments, statistics quality is often more important than fragmentation.
Key teaching point: Never run aggressive index rebuilds “because it’s Sunday.”
Maintenance should match workload, SLAs, and real evidence.
Demo goal: show students how one targeted index can reduce logical reads and improve query duration.
Focus on proof: compare “before” vs “after” using reads, CPU time, and the execution plan.
Use these settings to show IO and timing output for demonstration queries:
-- Demo: show the proof (reads + CPU time) SET STATISTICS IO ON; SET STATISTICS TIME ON; -- Run your slow query here (before index) -- Observe: logical reads, CPU time, duration, and plan operators -- Create your targeted index here (in demo database) -- Re-run query (after index) and compare results SET STATISTICS IO OFF; SET STATISTICS TIME OFF;
Students will analyze a query pattern, propose an index (key + INCLUDE), and explain tradeoffs (read gain vs write cost).
This is the exact skill expected in DBA interviews and real production troubleshooting.
Prompt:
“What is worse in production: a missing index that causes high reads, or too many indexes that slow down writes?
Explain your answer with one real-world example (reporting system, e-commerce orders, banking transactions, etc.).”
In the next lesson, we move into Query Optimization Techniques. Indexes are critical, but they are only one part of tuning.
You will learn how SQL Server chooses execution plans, how to read plans confidently, and how to rewrite queries to reduce work,
eliminate unnecessary reads, and prevent performance regressions.
Not a member yet? Register now
Are you a member? Login now