SQL Server: Wide Rows — Seeks Don’t Care, Scans Do
The same 24 rows, stored narrow and stored wide
SELECT
*
FROM
dbo.Users
WHERE
Id = 12345;
-- a seek
SELECT
*
FROM
dbo.Users;
-- no WHERE: read it all — a scan
Narrow: Id, DisplayName
Root page 1:500
Id 1 → 1:501 · Id 9 → 1:502 · Id 17 → 1:503
Page 1:501
Page 1:502
Page 1:503
Id 12,345
8 rows fit on each 8 KB page → 3 pages
page reads:
—
2 (root + one leaf)
3 (every page)
Wide: + AboutMe, WebsiteUrl, Location, …
Root page 1:700
Id 1 → 1:701 · Id 3 → 1:702 · ⋯ · Id 23 → 1:712
1:701
1:702
1:703
1:704
1:705
1:706
1:707
1:708
1:709
1:710
1:711
1:712
Id 12,345
only 2 fat rows fit per page → 12 pages
page reads:
—
2 (root + one leaf)
12 (every page)
seek: 2 reads = 2 reads — width didn’t matter
scan: 3 vs 12 pages — the width tax