โ† Simulation Lab

๐Ÿ—„๏ธ Speed up a slow database search

Software & Cloud

An orders table keeps growing. Searching it without an index reads every row. An index makes searches fast but every extra index slows down saving new orders. (Illustrative timings.)

โญ Level 1: Trainee0 XP ยท next level at 300
๐ŸŽฏ The orders page takes ages at 8 million rows. Get one search under 50 ms.
Controls
Results
One searchโœ— 400 ms
Database time on searches per day333.3 min
Saving one new orderโœ“ 0.2 ms

Searches scan the whole table: index the column you filter by.

๐Ÿ“˜ How it works

Without an index the database reads every row (time grows with table size). A B-tree index finds a row in a few steps (time grows with log of size). Indexes are not free: each one is updated on every insert.

Scan โˆ rows ยท Index lookup โˆ logโ‚‚(rows) ยท Insert โˆ 1 + number of indexesA simplified textbook model for learning. Real designs follow the full codes and standards.