How we made search return in under 100 milliseconds
A million issues, a hundred filters and one input box. What we tried, what we measured, and the index we ended up with.
Sofia LindqvistEngineering, Search · 9 min read
Last spring, search on our largest workspace took 1.8 seconds at the 95th percentile. People had stopped using it; they scrolled instead. This is how we got it under 100 milliseconds, and what we’d do differently.
What we measured
We logged every query for two weeks, with its filters and the time each stage took. Three things stood out:
- Most queries were two words or fewer.
- Nine in ten had at least one filter, usually
statusorassignee. - Half the time went to sorting results we never showed.
The index
We moved from one big index to one per workspace, with the common filters stored beside each word. A query now reads only the rows that can match:
const hits = index.search(words, {
filter: { status: ["todo", "doing"] },
limit: 50,
})Filters stored beside the words cost 12% more disk. We decided that was worth it; see the numbers.
Ranking without a second pass
Sorting moved into the index too: each list of matches is kept in order of last update, so the first 50 are the 50 we show. No second pass.
I typed half a word and it was there. I thought I’d hit a cached page.
What we’d do differently
Measure first. We spent a month on a faster tokenizer before we learned that tokenizing took 3% of the time.