DB Internals AtlasPostgreSQL 18.6 Home About

Parameter · Resource Usage / Memory

huge_pages

Use of huge pages on Linux or Windows.

  • Default: try
  • Type: enum
  • Values: off · on · try
  • Applies: Restart required

In plain words

Operating systems manage memory in small 4 kB pages. With a big shared buffers area that means millions of page-table entries, repeated in every PostgreSQL process. Huge pages (usually 2 MB) cut that overhead dramatically.

try uses them if available, on refuses to start without them, off never asks.

For DBAs and operators

Applies only to the main shared memory segment (shared buffers, WAL buffers, lock tables, SLRUs …), on Linux (only with shared_memory_type = mmap) and Windows. The OS must have huge pages reserved in advance:

-- how many pages this configuration needs (server may be stopped:
-- postgres -D $PGDATA -C shared_memory_size_in_huge_pages)
SHOW shared_memory_size_in_huge_pages;
SHOW huge_pages_status;     -- on / off / unknown (PG17+)
# Linux: vm.nr_hugepages = that number (+ a little), and check
grep Huge /proc/meminfo

With try and no pages reserved the server silently falls back to normal pages, which is why huge_pages_status (PostgreSQL 17+) is the thing to check after a restart. With on, a shortage stops startup with FATAL: could not map anonymous shared memory: Cannot allocate memory and a hint that the request may have exceeded available huge pages.

Why support cares

  • Large shared_buffers (tens of GB) plus hundreds of connections without huge pages wastes gigabytes on page tables (PageTables: in /proc/meminfo) and adds TLB misses.
  • Transparent huge pages (THP) are a different, automatic kernel feature; set it to madvise or never for PostgreSQL hosts.
  • Reserved huge pages are not usable by anything else; reserve only what PostgreSQL needs.

How to change it

Change in postgresql.conf or ALTER SYSTEM, then restart the server.

See it in context

Memory architecture Shared buffers

Related parameters

huge_page_size shared_buffers shared_memory_type min_dynamic_shared_memory

All Resource Usage parameters