---
title: "How we configure huge pages in ClickHouse Managed Postgres"
description: "ClickHouse Managed Postgres runs every server's shared_buffers on 2MB huge pages, which avoids per-backend page-table bloat and improves TLB reach."
url: "https://swe.quest/articles/how-we-configure-huge-pages-in-clickhouse-managed-postgres-6544ec044914bebf"
canonical: "https://clickhouse.com/blog/huge-pages-clickhouse-managed-postgres"
source: "ClickHouse"
published: "2026-07-14"
difficulty: "medium"
kind: "Case study"
reading_minutes: 5
tags: ["postgres","linux","performance","memory-management","configuration"]
---

# How we configure huge pages in ClickHouse Managed Postgres

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2026-07-14, 5 min read, Case study. Original: [https://clickhouse.com/blog/huge-pages-clickhouse-managed-postgres](https://clickhouse.com/blog/huge-pages-clickhouse-managed-postgres)

## Summary

ClickHouse Managed Postgres runs every server's shared\_buffers on 2MB huge pages, which avoids per-backend page-table bloat and improves TLB reach. The setup has three parts. A quarter of RAM is reserved as huge pages before Postgres starts, after dropping caches and compacting memory. Postgres is pinned to huge\_pages='on' so it fails at boot instead of silently falling back to 4KB pages. shared\_buffers is sized in two passes using \`postgres -C shared\_memory\_size\` so the full segment, including roughly 750MB of overhead, fits the pool. On an r7i.4xlarge with 32GB shared\_buffers, page tables grew 31MB per connection with 4KB pages (6.1GB at 200 connections) versus 111MB total with huge pages, and select-only pgbench throughput rose 12%.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Linux](https://swe.quest/tags/linux.md) (Infrastructure)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Memory management](https://swe.quest/tags/memory-management.md) (Compilers & runtimes)
- [Configuration management](https://swe.quest/tags/configuration.md) (Reliability & operations)

## Prerequisites

- PostgreSQL configuration ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- virtual memory and page tables
- Linux sysctl ([easy posts on Linux](https://swe.quest/tags/linux.md?difficulty=easy))

## Keywords

PostgreSQL, huge pages, shared\_buffers, TLB, pgbench, ClickHouse Managed Postgres, pg\_prewarm

## Related posts

- [Improving Lakebase Postgres Compute Cache on Neon, Part 1](https://swe.quest/articles/improving-lakebase-postgres-compute-cache-on-neon-part-1-96696f73ade727a0.md): Neon · 2026-09-09 · Hard · 9 min read · PostgreSQL, Caching, Performance engineering, Memory management, Virtualization
  On large fixed-size Lakebase Postgres computes, Neon now disables its NVMe-backed local file cache and sets shared buffers to 75% of DRAM (up from a 1 GB cap), backed by explicit 2 MB HugeTLB pages provisioned through host, hypervisor and guest VM.
- [Benchmarking NVMe-backed Managed Postgres: PlanetScale and ClickHouse](https://swe.quest/articles/benchmarking-nvme-backed-managed-postgres-planetscale-and-clickhouse-9c60dc3e275ce910.md): ClickHouse · 2026-07-30 · Medium · 4 min read · PostgreSQL, Performance engineering, Databases, Cloud platforms
  On identical AWS r8gd instances with local NVMe and quorum synchronous replication, ClickHouse Managed Postgres outperformed PlanetScale Metal in a pgbench TPC-B-like workload.
- [Supercharging your large ClickHouse data loads - Part 2: Tuning a large data load for speed](https://swe.quest/articles/supercharging-your-large-clickhouse-data-loads-part-2-tuning-a-large-data-load-646edfb3ee681d30.md): ClickHouse · 2023-10-18 · Medium · 10 min read · Analytics & OLAP, Performance engineering, Data pipelines, Scaling
  Tuning insert block size and insert parallelism lets a 65-billion-row (~14 TiB raw) PyPI load into ClickHouse run almost 3x faster than with default settings on the same hardware.
- [PostgresBench: A Reproducible Benchmark for Postgres Services](https://swe.quest/articles/postgresbench-a-reproducible-benchmark-for-postgres-services-3a30213211ea6b71.md): ClickHouse · 2026-04-02 · Medium · 9 min read · PostgreSQL, Performance engineering, Storage systems, Cloud platforms
  PostgresBench is an open, reproducible benchmark for managed Postgres services built on pgbench's TPC-B-like workload (256 clients, 16 threads, 10-minute runs, three runs each) at ~100 GB and ~500 GB scale factors, with default configs, HA disabled and all services in us-east-2.
- [Can your Postgres survive a bad query?](https://swe.quest/articles/can-your-postgres-survive-a-bad-query-744ea9a22b65710c.md): ClickHouse · 2026-09-28 · Hard · 13 min read · PostgreSQL, Memory management, Resilience, Query engines, Linux
  Postgres's \`work\_mem\` limits memory per plan node per process, not per query, so parallel workers and \`hash\_mem\_multiplier\` can push a simple aggregation past 8x \`work\_mem\`.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
