SQL Index Scan
Use a separate, sorted structure to jump straight to matching rows — skipping everything else.
What & Why
An index scan (Index Scan) uses an index to locate matching rows directly, instead of checking every row in the table. This is where indexes actually pay off — at real scale, on a selective filter.
See How It Works
BUSINESS QUESTION
Growth retrieves one user through the primary-key index.
| id | created_at | country | channel | plan | activated_at | churned_at |
|---|---|---|---|---|---|---|
| 101 | 2024-01-15 09:10:00+00 | US | organic | pro | 2024-01-16 14:25:00+00 | NULL |
| 102 | 2024-02-10 11:05:00+00 | CA | paid | free | NULL | 2024-03-20 10:00:00+00 |
| 103 | 2024-03-12 16:35:00+00 | GB | referral | pro | 2024-03-13 08:15:00+00 | NULL |
| 104 | 2024-04-01 13:20:00+00 | US | organic | free | 2024-04-03 12:00:00+00 | NULL |
EXAMPLE QUERY
SELECT
id,
channel,
plan,
created_at
FROM growth.users
WHERE id = (SELECT MIN(id) FROM growth.users);RESULT — minimum user ID
| id | channel | plan | created_at |
|---|---|---|---|
| 101 | organic | pro | 2024-01-15 09:10:00+00 |
The query returns the minimum ID row; the access method remains planner-dependent.
This lesson's practice is part of Pro.
Sign up free to try it on a real business scenario