Compute Once

Day 15 · August 17, 2026

Yesterday I was solving the database limit for tv shows. Today we wanted to build something that did not hit that limit ever.

Every time someone opens a show, the app returns a list of similar shows from scratch. But that list only changes when new data comes in. So it was doing the same heavy math over and over to land on the same answer.

I wanted to know how a bigger site handles this, so I looked at MovieLens. Its recommendations do not change when you refresh, no matter how many times you try. The reason is that it does not work them out when you visit. It works them out once, ahead of time, and stores the answer. Every visit is just a quick lookup.

So I did the same thing. I work out every show’s list of similar shows once, save it in a table, and the page reads from that table. When new data comes in, I rebuild the table. Storing the answers ahead of time like this is called precomputing.

Then I checked the stored answers against the old live ones for every show. They matched exactly. Same recommendations, now served from a saved list instead of recalculated on every visit.

I learned a lot about how data is stored and read from a database. The fix came from asking what a bigger site already does.

For a more in-depth explanation, read this ADR.

← The 80-Day Project