{"Entry":{"collection":"guc","key":"shared_buffers","name":"shared_buffers","aliases":[],"metadata":{"baseline":true,"boot_human":"Not specified","boot_val":null,"category":"Resource Usage / Memory","category_zh":"","changed_in":["15"],"changes":[{"documentation_changed":true,"fields":{},"from":"7.4","status":"changed","to":"8.0"},{"documentation_changed":true,"fields":{},"from":"8.0","status":"changed","to":"8.1"},{"documentation_changed":true,"fields":{},"from":"8.1","status":"changed","to":"8.2"},{"documentation_changed":true,"fields":{},"from":"8.2","status":"changed","to":"8.3"},{"documentation_changed":true,"fields":{},"from":"8.3","status":"changed","to":"8.4"},{"documentation_changed":true,"fields":{},"from":"9.2","status":"changed","to":"9.3"},{"documentation_changed":true,"fields":{},"from":"9.4","status":"changed","to":"9.5"},{"documentation_changed":true,"fields":{},"from":"9.6","status":"changed","to":"10"},{"documentation_changed":true,"fields":{},"from":"11","status":"changed","to":"12"},{"documentation_changed":false,"fields":{"boot_val":{"from":"1024","to":"16384"}},"from":"14","status":"changed","to":"15"}],"content_hash":"5e924cff31ec6099e62d7c0a1f26e292cd00a2a6953fe89992b39862cad8f66f","context":"","default_changed_in":["15"],"default_history":[{"from":"9.0","to":"14","value":"8 MiB (1024 × 8kB)"},{"from":"15","to":"19","value":"128 MiB (16384 × 8kB)"}],"derived_content_hash":"a2d0a26a938c5e87efe48ae5bbdee06a029b539483d067d1fda31ccdec2c2e1e","editorial":{"advice":{"olap":"Benchmark shared_buffers with representative bulk and scan phases. Include sustained throughput, spill/writeback, and interference with other sessions, not only one operation's elapsed time.","oltp":"Change shared_buffers only after identifying the corresponding resource bottleneck under concurrency. Budget total memory, I/O, disk, or kernel capacity rather than optimizing one process in isolation.","small":"Keep shared_buffers conservative on a small host and prefer the upstream default when evidence is weak. A setting copied from a large server can consume a disproportionate share of resources."},"mechanism":["shared_buffers allocates PostgreSQL's real shared buffer cache at server start. Pages cached here are PostgreSQL-managed and coexist with the operating system page cache; the setting is not merely a planner estimate.","The PG10-14 Docker boot value in this catalog is 8MB while PG15-18 report 128MB, reflecting historical initdb/container defaults rather than a universal hardware recommendation. The official guidance treats about 25% of RAM as a starting point for a dedicated server and rarely expects more than 40% to help.","A larger cache changes checkpoint and WAL pressure, often requiring a larger max_wal_size, and leaves less memory for backend processes, work_mem, maintenance, extensions, and the OS. Buffer allocation uses BLCKSZ units, normally 8kB. Its postmaster context fixes the value at server start; changing it requires a restart."],"pitfalls":["Changing shared_buffers without applying its documented unit and configuration context.","Optimizing an isolated benchmark while ignoring concurrent aggregate resource use.","Assuming a configured value guarantees operating-system or storage behavior.","Failing to retest startup, failover, and workload latency after the change."],"references":[{"title":"PostgreSQL 19 Beta 4: shared_buffers","url":"https://www.postgresql.org/docs/19/runtime-config-resource.html#GUC-SHARED-BUFFERS"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["effective_cache_size","work_mem","max_wal_size","huge_pages","checkpoint_completion_target","wal_buffers"],"summary":"shared_buffers — Sets the number of shared memory buffers used by the server. Observed in PG9.0–19 Beta 4; its last measured boot default is 128 MiB (16384 × 8kB) in PG19 Beta 4, with postmaster context. This is a beta-snapshot fact and can change before PostgreSQL 19 GA."},"enumvals":[],"first_version":"7.4","group":"Resource Usage","group_slug":"resource","imported_at":"2026-09-27T17:57:31.963059+08:00","intro_commit":{},"key":"shared_buffers","last_version":"20","max_val":"","min_val":"","name":"shared_buffers","position":357,"present_in":["7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"repair_provenance":{"original_source_revision":"english-manuals:037c09e223db9df8f87977b3a242b37a97dfe10318ad50ec287db034edb14c14","receipt_sha256":"f40d2a4136ca56259f5eb6c3cc672a522b4522ccef6901238f5a5ff39eb9a470","repair":"wiki-repair-20261023"},"short_desc":"Sets the amount of memory the database server uses for shared memory buffers.","short_desc_zh":"","source_rev":"wiki-repair-20261023:7f4bf1ada52d662025394cb13aa1604807192335f790090b8c0dbd22dfc8a037","unit":"","vartype":"integer"}},"Definition":{"Collection":"guc","Key":"shared_buffers","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"shared_buffers","SourceRevision":"wiki-repair-20261023:7f4bf1ada52d662025394cb13aa1604807192335f790090b8c0dbd22dfc8a037","Facts":{"boot_val":"16384","category":"Resource Usage / Memory","context":"postmaster","description":"Sets the amount of memory the database server uses for shared memory buffers. The default is typically 128 megabytes (128MB), but might be less if your kernel settings will not support it (as determined during initdb). This setting must be at least 128 kilobytes. However, settings significantly higher than the minimum are usually needed for good performance. If this value is specified without units, it is taken as blocks, that is BLCKSZ bytes, typically 8kB. (Non-default values of BLCKSZ change the minimum value.) This parameter can only be set at server start. If you have a dedicated database server with 1GB or more of RAM, a reasonable starting value for shared_buffers is 25% of the memory in your system. There are some workloads where even larger settings for shared_buffers are effective, but because PostgreSQL also relies on the operating system cache, it is unlikely that an allocation of more than 40% of RAM to shared_buffers will work better than a smaller amount. Larger settings for shared_buffers usually require a corresponding increase in max_wal_size, in order to spread out the process of writing large quantities of new or changed data over a longer period of time. On systems with less than 1GB of RAM, a smaller percentage of RAM is appropriate, so as to leave adequate space for the operating system.","description_zh":"设置数据库服务器用于共享内存缓冲区的内存量。默认值通常为 128 兆字节（128MB），但如果内核设置不支持，则可能更小（在 initdb 期间确定）。此设置必须至少为 128 千字节。不过，要获得良好性能，通常需要远高于该最小值的设置。如果指定值时没有单位，则以块为单位，即 BLCKSZ 字节，通常为 8kB。（BLCKSZ 的非默认值会改变该最小值。）此参数只能在服务器启动时设置。 如果专用数据库服务器具有 1GB 或更多内存，shared_buffers 的合理初始值是系统内存的 25%。对于某些工作负载，将 shared_buffers 设得更大也有效，但由于 PostgreSQL 同时依赖操作系统缓存，将超过 40% 的内存分配给 shared_buffers 不太可能比更小的值效果更好。将 shared_buffers 设得更大时，通常还需要相应增加 max_wal_size，以便将大量新数据或已修改数据的写入过程分散到更长的时间内。 对于内存少于 1GB 的系统，适合使用更小的内存比例，以便为操作系统留出足够空间。","description_zh_html":"\u003cp\u003e\n        设置数据库服务器用于共享内存缓冲区的内存量。默认值通常为 128 兆字节（\u003ccode class=\"literal\"\u003e128MB\u003c/code\u003e），但如果内核设置不支持，则可能更小（在 \u003cspan class=\"application\"\u003einitdb\u003c/span\u003e 期间确定）。此设置必须至少为 128 千字节。不过，要获得良好性能，通常需要远高于该最小值的设置。如果指定值时没有单位，则以块为单位，即 \u003ccode class=\"symbol\"\u003eBLCKSZ\u003c/code\u003e 字节，通常为 8kB。（\u003ccode class=\"symbol\"\u003eBLCKSZ\u003c/code\u003e 的非默认值会改变该最小值。）此参数只能在服务器启动时设置。\n       \u003c/p\u003e\u003cp\u003e\n        如果专用数据库服务器具有 1GB 或更多内存，\u003ccode class=\"varname\"\u003eshared_buffers\u003c/code\u003e 的合理初始值是系统内存的 25%。对于某些工作负载，将 \u003ccode class=\"varname\"\u003eshared_buffers\u003c/code\u003e 设得更大也有效，但由于 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 同时依赖操作系统缓存，将超过 40% 的内存分配给 \u003ccode class=\"varname\"\u003eshared_buffers\u003c/code\u003e 不太可能比更小的值效果更好。将 \u003ccode class=\"varname\"\u003eshared_buffers\u003c/code\u003e 设得更大时，通常还需要相应增加 \u003ccode class=\"varname\"\u003emax_wal_size\u003c/code\u003e，以便将大量新数据或已修改数据的写入过程分散到更长的时间内。\n       \u003c/p\u003e\u003cp\u003e\n        对于内存少于 1GB 的系统，适合使用更小的内存比例，以便为操作系统留出足够空间。\n       \u003c/p\u003e","doc":{"anchor":"GUC-SHARED-BUFFERS","file":"runtime-config-resource.html","lang":"en","sha256":"2e207c599f0884dfbe594558c478a2c7c132578981071e980e2015f31dfce28c","slug":"18"},"documented":true,"enumvals":null,"extra_desc":null,"lang":"en","max_val":"1073741823","metadata_version":"18","min_val":"16","name":"shared_buffers","short_desc":"Sets the number of shared memory buffers used by the server.","source":"pg-settings-source-snapshot","translation_provenance":{"inputs":[{"kind":"current-pgdoc-translation","path":"/Users/vonng/pgsty/pgdoc/zh/18/html/runtime-config-resource.html","sha256":"f5fedbf88ec5f973aaf4e525c03e46dda2a2186dabee154e26780da96b2ac85a"}],"kind":"same-version-pgdoc","locale":"zh-Hans","source_revision":"b1b500221dbe5437cfca004d6b04d3f6e422765d","version":"18"},"unit":"8kB","vartype":"integer","zh_from":"same-version-pgdoc"},"ManualEvidence":{"doc":{"anchor":"GUC-SHARED-BUFFERS","file":"runtime-config-resource.html","lang":"en","sha256":"2e207c599f0884dfbe594558c478a2c7c132578981071e980e2015f31dfce28c","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"shared_buffers","SourceDatabase":"center","Version":"18","Locale":"en","Title":"shared_buffers","Summary":"Sets the amount of memory the database server uses for shared memory buffers. The default is typically 128 megabytes (128MB), but might be less if your kernel settings will not support it (as determined during initdb). This setting must be at least 128 kilobytes. However, settings significantly higher than the minimum are usually needed for good performance. If this value is specified without units, it is taken as blocks, that is BLCKSZ bytes, typically 8kB. (Non-default values of BLCKSZ change the minimum value.) This parameter can only be set at server start. If you have a dedicated database server with 1GB or more of RAM, a reasonable starting value for shared_buffers is 25% of the memory in your system. There are some workloads where even larger settings for shared_buffers are effective, but because PostgreSQL also relies on the operating system cache, it is unlikely that an allocation of more than 40% of RAM to shared_buffers will work better than a smaller amount. Larger settings for shared_buffers usually require a corresponding increase in max_wal_size, in order to spread out the process of writing large quantities of new or changed data over a longer period of time. On systems with less than 1GB of RAM, a smaller percentage of RAM is appropriate, so as to leave adequate space for the operating system.","BodyHTML":"\u003cp\u003eSets the amount of memory the database server uses for shared memory buffers. The default is typically 128 megabytes (128MB), but might be less if your kernel settings will not support it (as determined during initdb). This setting must be at least 128 kilobytes. However, settings significantly higher than the minimum are usually needed for good performance. If this value is specified without units, it is taken as blocks, that is BLCKSZ bytes, typically 8kB. (Non-default values of BLCKSZ change the minimum value.) This parameter can only be set at server start. If you have a dedicated database server with 1GB or more of RAM, a reasonable starting value for shared_buffers is 25% of the memory in your system. There are some workloads where even larger settings for shared_buffers are effective, but because PostgreSQL also relies on the operating system cache, it is unlikely that an allocation of more than 40% of RAM to shared_buffers will work better than a smaller amount. Larger settings for shared_buffers usually require a corresponding increase in max_wal_size, in order to spread out the process of writing large quantities of new or changed data over a longer period of time. On systems with less than 1GB of RAM, a smaller percentage of RAM is appropriate, so as to leave adequate space for the operating system.\u003c/p\u003e","SourceRevision":"wiki-repair-20261023:7f4bf1ada52d662025394cb13aa1604807192335f790090b8c0dbd22dfc8a037","ContentHash":"6b2b6a17fe30e5c6c3ff8a161be339bbf52154838459fbfd33be32a50a8e03f8","Payload":{"description":"Sets the amount of memory the database server uses for shared memory buffers. The default is typically 128 megabytes (128MB), but might be less if your kernel settings will not support it (as determined during initdb). This setting must be at least 128 kilobytes. However, settings significantly higher than the minimum are usually needed for good performance. If this value is specified without units, it is taken as blocks, that is BLCKSZ bytes, typically 8kB. (Non-default values of BLCKSZ change the minimum value.) This parameter can only be set at server start. If you have a dedicated database server with 1GB or more of RAM, a reasonable starting value for shared_buffers is 25% of the memory in your system. There are some workloads where even larger settings for shared_buffers are effective, but because PostgreSQL also relies on the operating system cache, it is unlikely that an allocation of more than 40% of RAM to shared_buffers will work better than a smaller amount. Larger settings for shared_buffers usually require a corresponding increase in max_wal_size, in order to spread out the process of writing large quantities of new or changed data over a longer period of time. On systems with less than 1GB of RAM, a smaller percentage of RAM is appropriate, so as to leave adequate space for the operating system."}},"RequestedLocale":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
