{"Entry":{"collection":"guc","key":"huge_pages","name":"huge_pages","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Resource Usage / Memory","category_zh":"","changed_in":["11"],"changes":[{"documentation_changed":false,"fields":{},"from":"9.3","status":"added","to":"9.4"},{"documentation_changed":true,"fields":{},"from":"9.5","status":"changed","to":"9.6"},{"documentation_changed":true,"fields":{"short_desc":{"from":"Use of huge pages on Linux.","to":"Use of huge pages on Linux or Windows."}},"from":"10","status":"changed","to":"11"},{"documentation_changed":true,"fields":{},"from":"11","status":"changed","to":"12"},{"documentation_changed":true,"fields":{},"from":"12","status":"changed","to":"13"},{"documentation_changed":true,"fields":{},"from":"13","status":"changed","to":"14"},{"documentation_changed":true,"fields":{},"from":"16","status":"changed","to":"17"}],"content_hash":"6c1c20160b444020e030b06e5d71ccd6aa1f7f107f07efd8751ebf41fa63a903","context":"","default_changed_in":[],"default_history":[{"from":"9.4","to":"19","value":"try"}],"editorial":{"advice":{"olap":"Large shared-memory footprints may benefit more, but calculate the required page count and leave memory for backends, query workspaces, and the OS. Benchmark rather than treating huge pages as an automatic throughput win.","oltp":"Use try while validating operating-system provisioning and huge_pages_status. Switch to on only when failure to obtain huge pages should deliberately block startup and the reservation is managed reliably across reboots.","small":"Leave try or use off when huge-page reservation would create more operational complexity than benefit. Do not reserve a large fraction of a small host without a complete memory budget."},"mechanism":["huge_pages affects the main shared-memory area and is evaluated only at server start. try requests huge pages and falls back to normal pages, on makes failure fatal, and off skips the request.","Explicit huge pages can reduce page-table size and CPU time spent on memory management, especially with a large contiguous shared-memory allocation. On Linux, PostgreSQL requires shared_memory_type=mmap and enough pre-provisioned huge pages; huge_pages_status reports the actual outcome.","Explicit HugeTLB pages are not the same as Linux Transparent Huge Pages. PostgreSQL documentation currently discourages THP for some Linux versions even while describing explicit huge pages as potentially beneficial."],"pitfalls":["Confusing explicit huge pages with Transparent Huge Pages.","Setting on before provisioning enough pages, causing PostgreSQL startup to fail.","Assuming the setting covers work_mem or other ordinary per-process allocations; it targets the main shared-memory area.","Checking configuration but not the runtime huge_pages_status result."],"references":[{"title":"PostgreSQL 19 Beta 4: huge_pages","url":"https://www.postgresql.org/docs/19/runtime-config-resource.html#GUC-HUGE-PAGES"},{"title":"PostgreSQL 18: Linux Huge Pages","url":"https://www.postgresql.org/docs/18/kernel-resources.html#LINUX-HUGE-PAGES"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["huge_page_size","huge_pages_status","shared_buffers","shared_memory_type","min_dynamic_shared_memory"],"summary":"Controls explicit huge-page use for PostgreSQL's main shared-memory area on supported operating systems."},"enumvals":[],"first_version":"9.4","group":"Resource Usage","group_slug":"resource","imported_at":"2026-09-27T17:57:31.361493+08:00","intro_commit":{"authored_at":"2014-03-03T20:52:48+02:00","discussion":[],"hash":"f8ce16d0d2645f3e223b1a68cd8f6b2fa3d56627","subject":"Rename huge_tlb_pages to huge_pages, and improve docs.","url":"https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=f8ce16d0d2645f3e223b1a68cd8f6b2fa3d56627"},"key":"huge_pages","last_version":"20","max_val":"","min_val":"","name":"huge_pages","position":169,"present_in":["9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"short_desc":"Controls whether huge pages are requested for the main shared memory area.","short_desc_zh":"","source_rev":"english-manuals:741dc2299965d10a4a4cbccea6beab0b6915b92b393164ae0aa10dadb8cb1d7b","unit":"","vartype":"enum"}},"Definition":{"Collection":"guc","Key":"huge_pages","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"huge_pages","SourceRevision":"english-manuals:741dc2299965d10a4a4cbccea6beab0b6915b92b393164ae0aa10dadb8cb1d7b","Facts":{"boot_val":"try","category":"Resource Usage / Memory","context":"postmaster","description":"Controls whether huge pages are requested for the main shared memory area. Valid values are try (the default), on, and off. This parameter can only be set at server start. With huge_pages set to try, the server will try to request huge pages, but fall back to the default if that fails. With on, failure to request huge pages will prevent the server from starting up. With off, huge pages will not be requested. The actual state of huge pages is indicated by the server variable huge_pages_status. At present, this setting is supported only on Linux and Windows. The setting is ignored on other systems when set to try. On Linux, it is only supported when shared_memory_type is set to mmap (the default). The use of huge pages results in smaller page tables and less CPU time spent on memory management, increasing performance. For more details about using huge pages on Linux, see Section 18.4.5. Huge pages are known as large pages on Windows. To use them, you need to assign the user right “Lock pages in memory” to the Windows user account that runs PostgreSQL. You can use Windows Group Policy tool (gpedit.msc) to assign the user right “Lock pages in memory”. To start the database server on the command prompt as a standalone process, not as a Windows service, the command prompt must be run as an administrator or User Access Control (UAC) must be disabled. When the UAC is enabled, the normal command prompt revokes the user right “Lock pages in memory” when started. Note that this setting only affects the main shared memory area. Operating systems such as Linux, FreeBSD, and Illumos can also use huge pages (also known as “super” pages or “large” pages) automatically for normal memory allocation, without an explicit request from PostgreSQL. On Linux, this is called “transparent huge pages” (THP). That feature has been known to cause performance degradation with PostgreSQL for some users on some Linux versions, so its use is currently discouraged (unlike explicit use of huge_pages).","doc":{"anchor":"GUC-HUGE-PAGES","file":"runtime-config-resource.html","lang":"en","sha256":"2e207c599f0884dfbe594558c478a2c7c132578981071e980e2015f31dfce28c","slug":"18"},"documented":true,"enumvals":["off","on","try"],"extra_desc":null,"lang":"en","max_val":null,"metadata_version":"18","min_val":null,"name":"huge_pages","short_desc":"Use of huge pages on Linux or Windows.","source":"pg-settings-source-snapshot","unit":null,"vartype":"enum"},"ManualEvidence":{"doc":{"anchor":"GUC-HUGE-PAGES","file":"runtime-config-resource.html","lang":"en","sha256":"2e207c599f0884dfbe594558c478a2c7c132578981071e980e2015f31dfce28c","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"huge_pages","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"huge_pages","Summary":"","BodyHTML":"\u003cp\u003e控制是否为主共享内存区域请求巨型页。有效值是\u003ccode\u003etry\u003c/code\u003e（默认）、\u003ccode\u003eon\u003c/code\u003e以及\u003ccode\u003eoff\u003c/code\u003e。该参数只能在服务器启动时设置。如果\u003ccode\u003ehuge_pages\u003c/code\u003e被设置为\u003ccode\u003etry\u003c/code\u003e，则服务器将尝试请求巨型页，但是如果失败会退回到默认的方式。如果为\u003ccode\u003eon\u003c/code\u003e，请求巨型页失败将使得服务器无法启动。如果为\u003ccode\u003eoff\u003c/code\u003e，则不会请求巨型页。实际是否使用巨型页由服务器变量\u003ca href=\"/docs/18/runtime-config-preset.html#GUC-HUGE-PAGES-STATUS\" rel=\"nofollow\"\u003ehuge_pages_status\u003c/a\u003e表示。\u003c/p\u003e\u003cp\u003e当前，只有Linux和Windows上支持这个设置。在其他系统上这个参数被设置为\u003ccode\u003etry\u003c/code\u003e时，它会被忽略。在Linux中，它只在\u003ccode\u003eshared_memory_type\u003c/code\u003e设置为\u003ccode\u003emmap\u003c/code\u003e（默认）的时候被支持。\u003c/p\u003e\u003cp\u003e巨型页的使用会导致更小的页表以及花费在内存管理上的 CPU 时间更少，从而提高性能。更多有关Linux上使用巨型页的细节请见\u003ca href=\"/docs/18/kernel-resources.html#LINUX-HUGE-PAGES\" rel=\"nofollow\"\u003e第 18.4.5 节\u003c/a\u003e。\u003c/p\u003e\u003cp\u003e巨型页在Windows上被称为大页面。要使用大页面，需要为运行\u003cspan\u003ePostgreSQL\u003c/span\u003e的Windows用户账号分配\u003cspan\u003e“\u003cspan\u003e在内存中锁定页面\u003c/span\u003e”\u003c/span\u003e的用户权限。可以使用Windows的组策略工具（gpedit.msc）来分配用户权限\u003cspan\u003e“\u003cspan\u003e在内存中锁定页面\u003c/span\u003e”\u003c/span\u003e。为了在命令窗口以独立进程（而不是Windows服务）的方式启动数据库服务器，命令窗口必须以管理员身份运行或者禁用用户访问控制（UAC）。当UAC被启用时，普通的命令窗口会在启动时收回用户权限\u003cspan\u003e“\u003cspan\u003e在内存中锁定页面\u003c/span\u003e”\u003c/span\u003e。\u003c/p\u003e\u003cp\u003e注意这种设置仅影响主共享内存区域。Linux、FreeBSD以及Illumos之类的操作系统也能为普通内存分配自动使用巨型页（也被称为\u003cspan\u003e“\u003cspan\u003e超级\u003c/span\u003e”\u003c/span\u003e页或者\u003cspan\u003e“\u003cspan\u003e大\u003c/span\u003e”\u003c/span\u003e页面），而不需要来自\u003cspan\u003ePostgreSQL\u003c/span\u003e的显式请求。在Linux上，这被称为\u003cspan\u003e“\u003cspan\u003etransparent huge pages\u003c/span\u003e”\u003c/span\u003e（THP，透明巨型页）。已知这种特性对某些Linux版本上的某些用户会导致\u003cspan\u003ePostgreSQL\u003c/span\u003e的性能退化，因此当前并不鼓励使用它（与\u003ccode\u003ehuge_pages\u003c/code\u003e的显式使用不同）。\u003c/p\u003e","SourceRevision":"2026-09-11@29c86d9","ContentHash":"eb0f59a9897edae2737bba49d1061a59120c94e3fa597277a782e4573ada6503","Payload":{"carried_from":"","carry_reason":"","doc_html":"\u003cp\u003e控制是否为主共享内存区域请求巨型页。有效值是\u003ccode class=\"literal\"\u003etry\u003c/code\u003e（默认）、\u003ccode class=\"literal\"\u003eon\u003c/code\u003e以及\u003ccode class=\"literal\"\u003eoff\u003c/code\u003e。该参数只能在服务器启动时设置。如果\u003ccode class=\"varname\"\u003ehuge_pages\u003c/code\u003e被设置为\u003ccode class=\"literal\"\u003etry\u003c/code\u003e，则服务器将尝试请求巨型页，但是如果失败会退回到默认的方式。如果为\u003ccode class=\"literal\"\u003eon\u003c/code\u003e，请求巨型页失败将使得服务器无法启动。如果为\u003ccode class=\"literal\"\u003eoff\u003c/code\u003e，则不会请求巨型页。实际是否使用巨型页由服务器变量\u003ca href=\"/docs/18/runtime-config-preset.html#GUC-HUGE-PAGES-STATUS\"\u003ehuge_pages_status\u003c/a\u003e表示。\u003c/p\u003e\u003cp\u003e当前，只有Linux和Windows上支持这个设置。在其他系统上这个参数被设置为\u003ccode class=\"literal\"\u003etry\u003c/code\u003e时，它会被忽略。在Linux中，它只在\u003ccode class=\"varname\"\u003eshared_memory_type\u003c/code\u003e设置为\u003ccode class=\"literal\"\u003emmap\u003c/code\u003e（默认）的时候被支持。\u003c/p\u003e\u003cp\u003e巨型页的使用会导致更小的页表以及花费在内存管理上的 CPU 时间更少，从而提高性能。更多有关Linux上使用巨型页的细节请见\u003ca href=\"/docs/18/kernel-resources.html#LINUX-HUGE-PAGES\" title=\"18.4.5. Linux 大页\"\u003e第 18.4.5 节\u003c/a\u003e。\u003c/p\u003e\u003cp\u003e巨型页在Windows上被称为大页面。要使用大页面，需要为运行\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e的Windows用户账号分配\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003e在内存中锁定页面\u003c/span\u003e”\u003c/span\u003e的用户权限。可以使用Windows的组策略工具（gpedit.msc）来分配用户权限\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003e在内存中锁定页面\u003c/span\u003e”\u003c/span\u003e。为了在命令窗口以独立进程（而不是Windows服务）的方式启动数据库服务器，命令窗口必须以管理员身份运行或者禁用用户访问控制（UAC）。当UAC被启用时，普通的命令窗口会在启动时收回用户权限\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003e在内存中锁定页面\u003c/span\u003e”\u003c/span\u003e。\u003c/p\u003e\u003cp\u003e注意这种设置仅影响主共享内存区域。Linux、FreeBSD以及Illumos之类的操作系统也能为普通内存分配自动使用巨型页（也被称为\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003e超级\u003c/span\u003e”\u003c/span\u003e页或者\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003e大\u003c/span\u003e”\u003c/span\u003e页面），而不需要来自\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e的显式请求。在Linux上，这被称为\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003etransparent huge pages\u003c/span\u003e”\u003c/span\u003e（THP，透明巨型页）。已知这种特性对某些Linux版本上的某些用户会导致\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e的性能退化，因此当前并不鼓励使用它（与\u003ccode class=\"varname\"\u003ehuge_pages\u003c/code\u003e的显式使用不同）。\u003c/p\u003e","doc_same_as":""}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
