๐๏ธ Speed up a slow database search
Software & CloudAn 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
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.