Skip to main content

// advent-of-postgres/day-2

Day 2 of 24BeginnerAggregatesHAVINGNumeric division

The Error Budget

Every service has an error budget. Find the service that burned the most of it on 2 December, without letting a tiny service or integer division fool you.

Opens 2 December 2026, 00:00 UTC

Bushy keeps the error budgets. Each service may fail a small share of its requests before the team stops shipping features and fixes reliability instead. The dashboard broke overnight, so Bushy needs the numbers from the database.

Every service writes one row per minute to request_stats:

Column Type Notes
service text Part of the primary key
minute timestamptz The start of the minute, 2 December only
requests int Requests served in that minute
errors int How many of them returned a 5xx

Some minutes had no traffic at all. One service is a small export job that serves only a few thousand requests a day.

Your task

The error rate of a service is its total errors divided by its total requests over the whole day. Counting only services that served at least 10,000 requests on 2 December, which service had the highest error rate?

Submit the service name.

Stuck? Show a hint

Integer divided by integer is an integer in Postgres. And check what the 10,000-request floor removes.

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.