Back to the pile

The list that crawls

Forty crumbs in the feed, dozens of database queries to build it. The data's right; the page just visits the database once per row.

nodeChewy~25 min
1

Fresh from the oven

Clone it down and have a look around.

$git clone https://github.com/loaf-crumbs/list-that-crawls.git
2

The scenario

A feed endpoint returns the most recent crumbs, each tagged with its author's name. The response is correct — right crumbs, right authors — but it's slow, and it reports two numbers that explain why: how many database queries it ran, and how many milliseconds it took. For a 40-item feed, the query count is in the forties. Ask for fewer items and the count drops in lockstep; ask for more and it climbs the same way. The number of database round trips is tracking the number of rows, one to one, plus one. That's the smell. A feed of N items should not cost N+1 trips to the database — it should cost a small, constant handful regardless of how long the list is. The list query is fine on its own. It's what happens *after* it — once per row — that turns a quick lookup into a crawl. Return exactly the same feed while keeping the query count flat as the list grows.
3

What done looks like

- The feed returns the same crumbs with the same author names as before - The number of database queries stays small and constant as `limit` grows - A larger feed is meaningfully faster than it is today - No author is dropped, duplicated, or mislabelled
4

Stuck?

Peek if you need to — they get more specific as you go.

5

Taste test

Send it in when you’re ready. We’ll see if it’s tasty.

When you've got the flag, paste it here.

No attempts yet.