Lesson 35/100

Tutorials SQL Server Tutorial

Filtered Index — Complete Guide

Filtered Index — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of SQL Server Tutorial on Toolliyo Academy.

On this page

SQL Server Tutorial · Lesson 35 of 100

Filtered Index

SQL basics ✓QueriesAdvanced

Queries · 2 — JOINs · ~6 min · SQL — Indexing & Performance

What is this?

A filtered index uses a WHERE clause on the index definition so it only stores a subset of rows — e.g. open orders or non-null emails.

Why should you care?

If 95% of rows are Closed, an index on open rows is smaller and faster for the queue that only cares about Open.

See it live — copy this example

Run in SQL Server Management Studio (SSMS) or Azure Data Studio.

USE DataVerse;
IF COL_LENGTH('dbo.Orders', 'Status') IS NULL
    ALTER TABLE dbo.Orders ADD Status VARCHAR(10) NOT NULL CONSTRAINT DF_Orders_Status DEFAULT ('Open');
CREATE NONCLUSTERED INDEX IX_Orders_Open_City
ON dbo.Orders (City, OrderId)
WHERE Status = 'Open';
SELECT OrderId, City
FROM dbo.Orders
WHERE Status = 'Open' AND City = N'Pune';

What happened?

  • The index leaf holds only Open rows.
  • The query’s Status = 'Open' predicate lets the optimizer use the filtered index.

Practice next

  1. Add Status if needed and create the filtered index.
  2. Run the Open + City query with actual plan.
  3. Query Status = 'Closed' and note it cannot use this index.
  4. Filter WHERE Email IS NOT NULL on Customers.
  5. Index only InStock = 1 products.

Remember

Filtered indexes store a row subset. Great for hot status values. Query predicates must align.

Open order queue

Fulfillment only works DataVerse Status = Open.

Outcome: Tiny filtered index beats a fat full-table index.

Interview prep for this lesson

Practice these questions aloud after reading—each links to a full structured answer.

Mid PDF Detailed
Slower Queries: Fragmented indexes cause the database engine to read more data?
Short answer: pages, slowing down query performance. Real-world example (ShopNest) ShopNest adds an index on Orders(CustomerId, CreatedAt) because “my recent orders” is queried constantly. Say this in the interview Defin…
Mid PDF Detailed
Indexing:?
Short answer: Create indexes on columns that are used in WHERE clauses, JOIN conditions, and ORDER BY clauses. Use covering indexes to avoid full table scans and improve performance. Real-world example (ShopNest) ShopNes…
Mid PDF Detailed
Faster Search: Indexes allow the database to locate rows much faster than a full?
Short answer: Faster Search: Indexes allow the database to locate rows much faster than a full? is a common interview topic in SQL & Databases. Give a clear definition, then one concrete example. Real-world example (…
Mid PDF Detailed
Large Tables: Indexes are especially helpful for large tables that are queried?
Short answer: Large Tables: Indexes are especially helpful for large tables that are queried? is a common interview topic in SQL & Databases. Give a clear definition, then one concrete example. Real-world example (Sh…
Mid PDF Detailed
Larger Indexes: Fragmentation can lead to larger index sizes and more disk space?
Short answer: Larger Indexes: Fragmentation can lead to larger index sizes and more disk space? is a common interview topic in SQL & Databases. Give a clear definition, then one concrete example. Real-world example (…
Questions on this lesson 0

Sign in to ask a question or upvote helpful answers.

No questions yet — be the first to ask!

SQL Server Tutorial
Course syllabus

SQL Server Tutorial

SQL — Foundations
SQL — SQL Queries & Clauses
SQL — Joins & Relationships
SQL — Indexing & Performance
SQL — Stored Procedures & Functions
SQL — Transactions & Concurrency
SQL — Advanced SQL Server
SQL — Security & High Availability
SQL — 2022 & Cloud
SQL — Real-World Projects
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details