---
title: "Dynamically estimating and scaling Postgres’ working set size"
url: https://daily.dev/posts/dynamically-estimating-and-scaling-postgres-working-set-size-n4s4r83ng
source_url: https://neon.com/blog/dynamically-estimating-and-scaling-postgres-working-set-size
type: article
source: "Neon"
published: 2026-07-09T06:57:38.655Z
updated: 2026-07-09T06:59:48.421Z
tags: ["postgresql"]
reading_time: 13
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Dynamically estimating and scaling Postgres’ working set size

**[Neon](https://daily.dev/sources/neontech)** · 13 min read · 0 upvotes · 0 comments

## Summary

Neon's engineering team explains how they implemented working-set-size-aware autoscaling for Postgres. The core challenge: estimating the current working set (pages actively accessed) to keep it in memory, since cache misses over a network are far more costly than local disk reads. A standard HyperLogLog approach over-counted because it accumulated all pages since startup. Their solution replaces HLL register bits with timestamps, enabling arbitrary sliding-window queries via a single data structure. The algorithm then searches for the 'end of a plateau' in working set size as the window grows, using a 5-minute minimum offset to avoid thrashing on bursty workloads and a 1-hour cap for stable ones. Scaling uses projected growth to pre-emptively allocate memory. Results show up to 8x throughput improvement, 100% cache hit rates in batch workloads, and 30% cost savings versus fixed-size compute with equivalent performance.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://neon.com/blog/dynamically-estimating-and-scaling-postgres-working-set-size>

## Similar posts on daily.dev

- [Why Postgres Breaks Kubernetes container\_memory\_working\_set\_bytes Metric](https://daily.dev/posts/why-postgres-breaks-kubernetes-container-memory-working-set-bytes-metric-8roseacip) · Planet PostgreSQL · 0 upvotes · 0 comments

---

Tags: [#postgresql](https://daily.dev/tags/postgresql)

[View this post on daily.dev](https://daily.dev/posts/dynamically-estimating-and-scaling-postgres-working-set-size-n4s4r83ng)
