How we configure huge pages in ClickHouse Managed Postgres
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%.
Related posts
- Improving Lakebase Postgres Compute Cache on Neon, Part 1
Neon hardMaster
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. Huge pages cut per-backend page table overhead by 512× and reduce TLB misses, lowering tail read latency by up to ~40% and CPU by up to ~30% in benchmarks. Production endpoints saw up to 2× throughput, 5× fewer storage GetPage requests and 5× lower CPU, with near-100% cache hit rates. Autoscaling computes with dynamic shared buffers are planned for part 2.
- Benchmarking NVMe-backed Managed Postgres: PlanetScale and ClickHouse
ClickHouse mediumAdept
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. Throughput was 34% higher at 4 vCPU and 51–54% higher at 16 vCPU on 100 GB and 500 GB datasets, with lower average latency. The gap is attributed to configuration rather than hardware: 2 MB huge pages (about 12% on their own), lz4 WAL compression, and max_wal_size sized to the instance (up to 256 GB) versus PlanetScale's 8 GB with huge pages and WAL compression disabled. The results come from a vendor benchmark, and the authors advise validating with your own workload.
- Supercharging your large ClickHouse data loads - Part 2: Tuning a large data load for speed
ClickHouse mediumAdept
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. On servers with 59 cores and 236 GiB RAM, the sweet spot was 32 insert threads with 10-million-row blocks. Larger blocks exhaust memory at higher thread counts, while using all cores for inserts starves background merges. A rule of thumb follows: set max_insert_threads to about half the cores, and set min_insert_block_size_bytes to target peak memory / (~3 × threads). With SharedMergeTree in ClickHouse Cloud, ingest throughput scales linearly as servers are added.
- PostgresBench: A Reproducible Benchmark for Postgres Services
ClickHouse mediumAdept
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. In the first cohort, ClickHouse's NVMe-backed managed Postgres reached about 28.7K TPS on 16 vCPU/64 GB at 100 GB, versus 14.8K for Crunchy Bridge, 12.6K for Aurora, 8.6K for Neon and 8.1K for RDS, and held about 26K TPS at 500 GB. ClickHouse attributes the lead to co-located local NVMe storage, which avoids network round trips on every fsync and WAL commit in write-heavy workloads. Scripts and raw JSON results are on GitHub for verification and community submissions, though the vendor-run setup and absence of pricing comparisons are worth weighing.
- Can your Postgres survive a bad query?
ClickHouse hardMaster
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`. Some structures never spill: the deduplication hashtable behind `WITH RECURSIVE ... UNION` stays in memory for the whole query and can grow unbounded. A benchmark ran 7-23 concurrent copies of such a query (~1 GiB each) against ClickHouse Managed Postgres, Cloud SQL, PlanetScale and RDS. With overcommit disabled, ClickHouse returned clean SQLSTATE 53200 errors and kept the cluster up in every run, while RDS hit the OOM killer and crash recovery from 19 connections and the supervisor-based providers terminated sessions or crashed under load.