Skip to main content

// advent-of-postgres/day-19

Day 19 of 24Advancedregr_slopeForecasting

The Disk That Fills Up

Fit a line to two weeks of disk usage and find the host that runs out of space first. The fullest disk today is not the answer.

Opens 19 December 2026, 00:00 UTC

Nobody wants a full disk on 24 December. Wunorse asks you which host will run out of space first if things keep growing the way they have for the last two weeks.

Every host reports its disk usage every six hours to disk_usage:

Column Type Notes
host text Part of the primary key
measured_at timestamptz Every 6 hours, from 5 December
used_gb numeric(8,2) Space used
size_gb int Size of the disk

The measurements are noisy, so use the least-squares line through all of a host's points as its growth rate. The free space is the size minus the usage at the host's last measurement.

Your task

At its own growth rate, which host runs out of disk space first?

Submit the host name.

Stuck? Show a hint

regr_slope(used_gb, extract(epoch from measured_at)) is the growth in GB per second. Divide the free space at the last measurement by it.

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.