A list scan needs 100 seconds a second.
transcript
A correct lookup can still fail. The traffic is too big for it. Count the work first. A payments app met this on day one.
A service stores a million payment ids. Twenty thousand requests arrive each second. Each asks: stored, or new? The answer must come back quickly. And it must stay quick as ids grow.
Keep the ids in a list. Scan it for every request. It is correct and short. Now count what it costs. The code is simple, and the answers are right.
One lookup averages half a million comparisons. Twenty thousand lookups make ten billion. At a hundred million a second, a hundred seconds. One machine falls behind at once. A hundred machines would be needed.
A hash table reads one bucket. A few steps for each lookup. Same answers, far less work. The data does not change. The method does.
Count before you build. Full breakdown in the lecture.