{"Entry":{"collection":"guc","key":"temp_buffers","name":"temp_buffers","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Resource Usage / Memory","category_zh":"","changed_in":[],"changes":[{"documentation_changed":false,"fields":{},"from":"8.0","status":"added","to":"8.1"},{"documentation_changed":true,"fields":{},"from":"8.1","status":"changed","to":"8.2"},{"documentation_changed":true,"fields":{},"from":"8.4","status":"changed","to":"9.0"},{"documentation_changed":true,"fields":{},"from":"11","status":"changed","to":"12"}],"content_hash":"907b60f16fa4c5b21f32bdcb04a35c8a8b269afa81d2d75984b7d651322f3b6e","context":"","default_changed_in":[],"default_history":[{"from":"9.0","to":"19","value":"8 MiB (1024 × 8kB)"}],"derived_content_hash":"dd30775df641890d72788b13eb135134cf7078e5775050c66b5a8a0f0f0e916b","editorial":{"advice":{"olap":"Raise it only for workflows that use PostgreSQL temporary tables; work_mem, not temp_buffers, is the primary control for sort and hash operations. Include session concurrency in the budget.","oltp":"Leave the default unless the application demonstrably uses sizable temporary tables. Prefer scoped changes in the sessions that create them and set the value before first access.","small":"Keep the default and avoid globally increasing per-session ceilings. Temporary-table-heavy jobs should be isolated or adjusted locally."},"mechanism":["temp_buffers controls session-local buffers for temporary-table access. It does not govern sort or hash spill files created by ordinary query execution.","A session can change the value only before its first use of a temporary table; later SET commands have no effect for that session. Buffers are allocated on demand up to the ceiling.","An unused increase still creates buffer-descriptor overhead, while each buffer actually used consumes one database block, normally 8kB. Aggregate usage therefore depends on the number of sessions actively using temporary tables."],"pitfalls":["Confusing temporary-table buffers with sort and hash temporary files.","Issuing SET after the session has already accessed a temporary table.","Ignoring multiplication across many sessions actively using temporary tables.","Assuming a large value is fully allocated immediately; PostgreSQL grows usage on demand, though descriptor overhead remains."],"references":[{"title":"PostgreSQL 19 Beta 4: temp_buffers","url":"https://www.postgresql.org/docs/19/runtime-config-resource.html#GUC-TEMP-BUFFERS"},{"title":"PostgreSQL 18: CREATE TEMPORARY TABLE","url":"https://www.postgresql.org/docs/18/sql-createtable.html"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["work_mem","temp_file_limit","temp_tablespaces","max_connections","log_temp_files"],"summary":"A per-session, lazily allocated buffer ceiling used only when accessing temporary tables."},"enumvals":[],"first_version":"8.1","group":"Resource Usage","group_slug":"resource","imported_at":"2026-09-27T17:57:32.152112+08:00","intro_commit":{},"key":"temp_buffers","last_version":"20","max_val":"","min_val":"","name":"temp_buffers","position":411,"present_in":["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:91457c118d2c7ec82e5c7c1879a3fba02bfc2146178502f0a415afda6f3dfe27","receipt_sha256":"a0fdb9b4f458bc99beb21deab0620bfdd48c48cfa5b08ba604591d926a9850a9","repair":"wiki-repair-20261023"},"short_desc":"Sets the maximum amount of memory used for temporary buffers within each database session.","short_desc_zh":"","source_rev":"wiki-repair-20261023:9d32c6ca3960de9337725a4b694a971a387a8ce62285ea34a66fa76c7da6e19d","unit":"","vartype":"integer"}},"Definition":{"Collection":"guc","Key":"temp_buffers","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"temp_buffers","SourceRevision":"wiki-repair-20261023:9d32c6ca3960de9337725a4b694a971a387a8ce62285ea34a66fa76c7da6e19d","Facts":{"boot_val":"1024","category":"Resource Usage / Memory","context":"user","description":"Sets the maximum amount of memory used for temporary buffers within each database session. These are session-local buffers used only for access to temporary tables. If this value is specified without units, it is taken as blocks, that is BLCKSZ bytes, typically 8kB. The default is eight megabytes (8MB). (If BLCKSZ is not 8kB, the default value scales proportionally to it.) This setting can be changed within individual sessions, but only before the first use of temporary tables within the session; subsequent attempts to change the value will have no effect on that session. A session will allocate temporary buffers as needed up to the limit given by temp_buffers. The cost of setting a large value in sessions that do not actually need many temporary buffers is only a buffer descriptor, or about 64 bytes, per increment in temp_buffers. However if a buffer is actually used an additional 8192 bytes will be consumed for it (or in general, BLCKSZ bytes).","description_zh":"设置每个数据库会话用于临时缓冲区的最大内存量。这些是会话本地的缓冲区，仅用于访问临时表。如果指定值时没有单位，则以块为单位，即 BLCKSZ 字节，通常为 8kB。默认值为 8 兆字节（8MB）。（如果 BLCKSZ 不是 8kB，则默认值按比例变化。）可以在单个会话内更改此设置，但必须在该会话首次使用临时表之前更改；此后尝试更改该值，对该会话不会产生影响。 会话会按需分配临时缓冲区，上限为 temp_buffers。对于实际不需要很多临时缓冲区的会话，将此参数设得较大时，开销仅为 temp_buffers 每增加一就多分配一个缓冲区描述符，约为 64 字节。不过，如果实际使用了某个缓冲区，还会为它额外消耗 8192 字节（一般而言为 BLCKSZ 字节）。","description_zh_html":"\u003cp\u003e\n        设置每个数据库会话用于临时缓冲区的最大内存量。这些是会话本地的缓冲区，仅用于访问临时表。如果指定值时没有单位，则以块为单位，即 \u003ccode class=\"symbol\"\u003eBLCKSZ\u003c/code\u003e 字节，通常为 8kB。默认值为 8 兆字节（\u003ccode class=\"literal\"\u003e8MB\u003c/code\u003e）。（如果 \u003ccode class=\"symbol\"\u003eBLCKSZ\u003c/code\u003e 不是 8kB，则默认值按比例变化。）可以在单个会话内更改此设置，但必须在该会话首次使用临时表之前更改；此后尝试更改该值，对该会话不会产生影响。\n       \u003c/p\u003e\u003cp\u003e\n        会话会按需分配临时缓冲区，上限为 \u003ccode class=\"varname\"\u003etemp_buffers\u003c/code\u003e。对于实际不需要很多临时缓冲区的会话，将此参数设得较大时，开销仅为 \u003ccode class=\"varname\"\u003etemp_buffers\u003c/code\u003e 每增加一就多分配一个缓冲区描述符，约为 64 字节。不过，如果实际使用了某个缓冲区，还会为它额外消耗 8192 字节（一般而言为 \u003ccode class=\"symbol\"\u003eBLCKSZ\u003c/code\u003e 字节）。\n       \u003c/p\u003e","doc":{"anchor":"GUC-TEMP-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":"100","name":"temp_buffers","short_desc":"Sets the maximum number of temporary buffers used by each session.","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-TEMP-BUFFERS","file":"runtime-config-resource.html","lang":"en","sha256":"2e207c599f0884dfbe594558c478a2c7c132578981071e980e2015f31dfce28c","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"temp_buffers","SourceDatabase":"center","Version":"18","Locale":"en","Title":"temp_buffers","Summary":"Sets the maximum amount of memory used for temporary buffers within each database session. These are session-local buffers used only for access to temporary tables. If this value is specified without units, it is taken as blocks, that is BLCKSZ bytes, typically 8kB. The default is eight megabytes (8MB). (If BLCKSZ is not 8kB, the default value scales proportionally to it.) This setting can be changed within individual sessions, but only before the first use of temporary tables within the session; subsequent attempts to change the value will have no effect on that session. A session will allocate temporary buffers as needed up to the limit given by temp_buffers. The cost of setting a large value in sessions that do not actually need many temporary buffers is only a buffer descriptor, or about 64 bytes, per increment in temp_buffers. However if a buffer is actually used an additional 8192 bytes will be consumed for it (or in general, BLCKSZ bytes).","BodyHTML":"\u003cp\u003eSets the maximum amount of memory used for temporary buffers within each database session. These are session-local buffers used only for access to temporary tables. If this value is specified without units, it is taken as blocks, that is BLCKSZ bytes, typically 8kB. The default is eight megabytes (8MB). (If BLCKSZ is not 8kB, the default value scales proportionally to it.) This setting can be changed within individual sessions, but only before the first use of temporary tables within the session; subsequent attempts to change the value will have no effect on that session. A session will allocate temporary buffers as needed up to the limit given by temp_buffers. The cost of setting a large value in sessions that do not actually need many temporary buffers is only a buffer descriptor, or about 64 bytes, per increment in temp_buffers. However if a buffer is actually used an additional 8192 bytes will be consumed for it (or in general, BLCKSZ bytes).\u003c/p\u003e","SourceRevision":"wiki-repair-20261023:9d32c6ca3960de9337725a4b694a971a387a8ce62285ea34a66fa76c7da6e19d","ContentHash":"077f6adf9625111cba7da96c3f0b8a6446c14659525c9a408190c9aa1839db5b","Payload":{"description":"Sets the maximum amount of memory used for temporary buffers within each database session. These are session-local buffers used only for access to temporary tables. If this value is specified without units, it is taken as blocks, that is BLCKSZ bytes, typically 8kB. The default is eight megabytes (8MB). (If BLCKSZ is not 8kB, the default value scales proportionally to it.) This setting can be changed within individual sessions, but only before the first use of temporary tables within the session; subsequent attempts to change the value will have no effect on that session. A session will allocate temporary buffers as needed up to the limit given by temp_buffers. The cost of setting a large value in sessions that do not actually need many temporary buffers is only a buffer descriptor, or about 64 bytes, per increment in temp_buffers. However if a buffer is actually used an additional 8192 bytes will be consumed for it (or in general, BLCKSZ bytes)."}},"RequestedLocale":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","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}
