Performance

Partial Indexes: Saving Space and Speed

SQL Mastery Team
April 22, 2026
5 min read

It's **Day 91**, and we're getting clever with **Partial Indexes**.

The Problem: Index Bloat

Imagine a table with 10 million rows. 9.9 million are "Closed" orders. Only 100,000 are "Active."

If you create a standard index on `status`, the index will be huge and slow because it includes all those millions of closed orders you never search for.

The Solution: The WHERE clause in an INDEX

CREATE INDEX idx_active_orders

ON orders (user_id)

WHERE status = 'Active';

Why this is a Pro Move

1. **Tiny Index Size**: The index is 100x smaller because it only stores the 100,000 active rows.

2. **Faster Writes**: The database only updates the index when an active order changes.

3. **Faster Reads**: The database doesn't have to sift through the "Noise" of millions of closed orders.

Your Task for Today

Identify a column with a "Status" (Active/Inactive, Sent/Pending). Create a partial index for only the "Important" status.

*Day 92: Covering Indexes (Avoiding the Heap).*

Ready to put your knowledge into practice?

Join SQL Mastery and learn through interactive exercises.