Day 10 10 min
Search autocomplete
1 / 6 · ≈ 14 min left
The problem
Yusuf types iph in the search box of an electronics shop. Before he types the next letter, a list drops down: "iPhone 15 Pro", "iPhone 15 case", "iPhone charger". He taps the first one.
The shop’s first version ran WHERE name ILIKE '%iph%' on the products table at each keystroke. At 1 million rows, every keystroke read the whole table, and the list showed up after the user had finished typing.
You design the suggestion service: 10 suggestions for what the user has typed so far, back before the next keystroke.