All labs
Lab 23
Database Scaling

Index vs Full Table Scan

Run a query with no index and watch the scanner sweep every row; add an index and it jumps straight to the answer. Grow the table and the scan explodes while the index stays flat.

ChatSphere's feed query is slow. Pick an index, pick the query, grow the table, and watch how many rows the database actually has to read to answer it.
Query
Index
100,000 rows
Rows read
100,000
Of table
100%
vs full scan
1ร—
faster
The whole table โ€” red = rows the engine had to read
Full table scan โ€” reading all 100,000 rows to find 50. Grows with every new post.
What just happened