Skip to main content

// advent-of-postgres/day-5

Day 5 of 24IntermediateOrdered-set aggregatespercentile_cont

The Slow Tail

Averages hide the requests that make users angry. Find the service with the worst 95th percentile latency.

Opens 5 December 2026, 00:00 UTC

Tinsel sets the latency targets. "Nobody complains about the average request," Tinsel says. "They complain about the slow ones. Give me the service with the worst tail."

Every request on 5 December is in requests:

Column Type Notes
id bigint Primary key
service text One of five services
started_at timestamptz When the request started
latency_ms int How long it took

The team measures the tail as the 95th percentile: the latency that 95% of requests stay under. One service has a few requests that took more than half a minute. That is not the same thing as a slow tail.

Your task

Which service had the highest 95th percentile latency on 5 December?

Submit the service name.

Stuck? Show a hint

percentile_cont(0.95) WITHIN GROUP (ORDER BY latency_ms) gives the 95th percentile. Compare it with avg() to see the trap.

No database yet. You get a real Postgres database on Neon, free, with no account.
One statement at a time. Ctrl+Enter or Cmd+Enter runs it.

Download today's data as SQL to solve it on your own Postgres (14 or later).

Solved this puzzle? Share it.

Tag @thedevopsdaily and share it with the community.