Skip to content
About
Main content
Special Shapes & Boundaries

Specialized Processing Models

What do you build when a query predicate cannot be reduced to a range over an ordered key?

Who this mechanism is for: a developer who writes code, calls APIs and knows basic SQL, and has probably used a search box, a "similar items" feature or a map, but has never looked inside the systems that power them. You do not need any database or systems background. Every technical term is explained the first time it appears, and again in the glossary at the end. This mechanism assumes only the short primer under "Before you start" below.

The story we will follow

Amara Okafor is a backend engineer at Haatly, a neighbourhood marketplace app ("haat" means local market). People list second-hand clothes, furniture and handmade goods. Buyers search and buy. About 4,000 couriers deliver within the city. Haatly has roughly 10 million listings, 2 million users and 300,000 deliveries a month. Everything lives in one PostgreSQL database with ordinary indexes, and for orders, users and payments that works very well.

Then the product team asks for five features: a search box that understands words, a "similar items" strip, "friends of friends who bought this", "couriers near me", and live courier and queue metrics. Amara's CTO, Elin Lindqvist, asks a fair question: "Why can't these all be ordinary SQL queries?" Amara's colleague Diego Ferreira, a data scientist, builds the behind "similar items".

Each article of this mechanism opens with a Haatly feature that was built "the obvious way" in SQL and that looks like a bug: a query that takes 9 seconds, a result page with three items instead of ten, a metrics store that falls over when one label is added. Each article ends with the solution, built from the mechanisms taught in that article. The numbers in the story are illustrations. The numbers in the teaching text come from the source analysis.

The main idea of this mechanism is this:

(Prune means "skip data that cannot be part of the answer without reading it".)

How this mechanism is organized

After that: a summary, hands-on labs, interview questions and a glossary.

One request: do not skip the arithmetic. Many sections turn on a few lines of simple multiplication (a 30 GB scan, a 1,000x fetch, 50 segments). The arithmetic is what makes each mechanism feel necessary rather than arbitrary.

What do I do, and what does each option cost?

Can I see it myself?

Can I reason about it under questioning?

Trade-offs

The tensions this mechanism takes a position on. Each recurs across mechanisms.

Show all 7 trade-offs
Recurring principles

Ideas this mechanism meets that keep coming back, mechanism after mechanism.

Show all 11 principles