{"Entry":{"collection":"guc","key":"enable_partitionwise_aggregate","name":"enable_partitionwise_aggregate","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Query Tuning / Planner Method Configuration","category_zh":"","changed_in":[],"changes":[{"documentation_changed":false,"fields":{},"from":"10","status":"added","to":"11"},{"documentation_changed":true,"fields":{},"from":"11","status":"changed","to":"12"}],"content_hash":"4d46c0c94d7f8d7ebc6c235a1c17d019e4f4b5e6ddac6a502bab975a35784b09","context":"","default_changed_in":[],"default_history":[{"from":"11","to":"19","value":"off"}],"derived_content_hash":"28a3909013c99fc8517d94fcf0a2cb9b863608493aba993035be7787ca2f780f","editorial":{"advice":{"olap":"Benchmark representative analytical plans with and without enable_partitionwise_aggregate. Judge planning time, memory, spill, and execution time together; a win for one report is not evidence for a global setting.","oltp":"Keep the upstream default for routine OLTP. Use a transaction- or session-local change to diagnose whether choosing per-partition grouping or aggregation, with later finalization when grouping keys do not contain partition keys explains a regression, then repair statistics, indexes, estimates, or query shape instead of leaving a cluster-wide method ban.","small":"Do not use enable_partitionwise_aggregate as a permanent hint on a small host. Resource pressure may change the best method, so verify with EXPLAIN (ANALYZE, BUFFERS) and keep the change scoped to the affected workload if it is still needed."},"mechanism":["enable_partitionwise_aggregate controls whether the planner may choose per-partition grouping or aggregation, with later finalization when grouping keys do not contain partition keys.","It is consulted while a plan is built. A session-level change is useful for comparing EXPLAIN alternatives, but an already cached plan is not retroactively rewritten; invalidation or replanning is required to observe a different choice.","It can multiply work_mem-limited nodes and planning effort roughly with the number of participating partitions. Its user context permits session- or transaction-local changes; newly performed or newly planned work sees the value."],"pitfalls":["Treating enable_partitionwise_aggregate as a query hint even though it affects every plan built in its scope.","Testing an already cached prepared plan and concluding that the setting has no effect.","Masking stale statistics or cardinality errors by disabling a plan method globally.","It can multiply work_mem-limited nodes and planning effort roughly with the number of participating partitions."],"references":[{"title":"PostgreSQL 19 Beta 4: enable_partitionwise_aggregate","url":"https://www.postgresql.org/docs/19/runtime-config-query.html#GUC-ENABLE-PARTITIONWISE-AGGREGATE"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["enable_partitionwise_join","enable_partition_pruning","work_mem","enable_hashagg","max_parallel_workers_per_gather"],"summary":"enable_partitionwise_aggregate — Enables partitionwise aggregation and grouping. Observed in PG11–19 Beta 4; its last measured boot default is off in PG19 Beta 4, with user context. This is a beta-snapshot fact and can change before PostgreSQL 19 GA."},"enumvals":[],"first_version":"11","group":"Query Tuning","group_slug":"query","imported_at":"2026-09-27T17:57:31.227906+08:00","intro_commit":{"authored_at":"2018-03-22T12:49:48-04:00","discussion":["https://postgr.es/m/CAM2+6=V64_xhstVHie0Rz=KPEQnLJMZt_e314P0jaT_oJ9MR8A@mail.gmail.com"],"hash":"e2f1eb0ee30d144628ab523432320f174a2c8966","subject":"Implement partition-wise grouping/aggregation.","url":"https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=e2f1eb0ee30d144628ab523432320f174a2c8966"},"key":"enable_partitionwise_aggregate","last_version":"20","max_val":"","min_val":"","name":"enable_partitionwise_aggregate","position":131,"present_in":["11","12","13","14","15","16","17","18","19","20"],"repair_provenance":{"original_source_revision":"english-manuals:30d67b102ec3fadfea237e2a83dc4b97f6de8a47482b53c4a107b0a7adc2440d","receipt_sha256":"78789b265c47950cf4d0446ad89adef259ae107556039c2d481ba382213635a2","repair":"wiki-repair-20261023"},"short_desc":"Enables or disables the query planner's use of partitionwise grouping or aggregation, which allows grouping or aggregation on partitioned tables to be performed separately for each partition.","short_desc_zh":"","source_rev":"wiki-repair-20261023:dcbc2fa5f6cacfd3ffc7006c4b3385b13d5791b27af4550b85d5dd542f156a55","unit":"","vartype":"bool"}},"Definition":{"Collection":"guc","Key":"enable_partitionwise_aggregate","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"enable_partitionwise_aggregate","SourceRevision":"wiki-repair-20261023:dcbc2fa5f6cacfd3ffc7006c4b3385b13d5791b27af4550b85d5dd542f156a55","Facts":{"boot_val":"off","category":"Query Tuning / Planner Method Configuration","context":"user","description":"Enables or disables the query planner's use of partitionwise grouping or aggregation, which allows grouping or aggregation on partitioned tables to be performed separately for each partition. If the GROUP BY clause does not include the partition keys, only partial aggregation can be performed on a per-partition basis, and finalization must be performed later. With this setting enabled, the number of nodes whose memory usage is restricted by work_mem appearing in the final plan can increase linearly according to the number of partitions being scanned. This can result in a large increase in overall memory consumption during the execution of the query. Query planning also becomes significantly more expensive in terms of memory and CPU. The default value is off.","description_zh":"启用或禁用查询规划器对分区分组或聚合的使用，使分区表上的分组或聚合可以在各个分区上分别执行。如果 GROUP BY 子句不包含分区键，则只能在各分区上执行部分聚合，随后还必须进行最终处理。启用此设置后，最终计划中内存用量受 work_mem 限制的节点数量可能随所扫描分区的数量线性增加。这可能大幅增加查询执行期间的总内存消耗。查询规划在内存和 CPU 方面的开销也会显著增加。默认值为 off。","description_zh_html":"\u003cp\u003e\n        启用或禁用查询规划器对分区分组或聚合的使用，使分区表上的分组或聚合可以在各个分区上分别执行。如果 \u003ccode class=\"literal\"\u003eGROUP BY\u003c/code\u003e 子句不包含分区键，则只能在各分区上执行部分聚合，随后还必须进行最终处理。启用此设置后，最终计划中内存用量受 \u003ccode class=\"varname\"\u003ework_mem\u003c/code\u003e 限制的节点数量可能随所扫描分区的数量线性增加。这可能大幅增加查询执行期间的总内存消耗。查询规划在内存和 CPU 方面的开销也会显著增加。默认值为 \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e。\n       \u003c/p\u003e","doc":{"anchor":"GUC-ENABLE-PARTITIONWISE-AGGREGATE","file":"runtime-config-query.html","lang":"en","sha256":"33456ca7ef52bf28e93e34b932a411db7a1b95800179add2cf867dc6ec9144bc","slug":"18"},"documented":true,"enumvals":null,"extra_desc":null,"lang":"en","max_val":null,"metadata_version":"18","min_val":null,"name":"enable_partitionwise_aggregate","short_desc":"Enables partitionwise aggregation and grouping.","source":"pg-settings-source-snapshot","translation_provenance":{"inputs":[{"kind":"current-pgdoc-translation","path":"/Users/vonng/pgsty/pgdoc/zh/18/html/runtime-config-query.html","sha256":"38b0ec7d6c52647c7cdf6401bda43777b62b324f1821fef3ee0f0f0ddb388513"}],"kind":"same-version-pgdoc","locale":"zh-Hans","source_revision":"b1b500221dbe5437cfca004d6b04d3f6e422765d","version":"18"},"unit":null,"vartype":"bool","zh_from":"same-version-pgdoc"},"ManualEvidence":{"doc":{"anchor":"GUC-ENABLE-PARTITIONWISE-AGGREGATE","file":"runtime-config-query.html","lang":"en","sha256":"33456ca7ef52bf28e93e34b932a411db7a1b95800179add2cf867dc6ec9144bc","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"enable_partitionwise_aggregate","SourceDatabase":"center","Version":"18","Locale":"en","Title":"enable_partitionwise_aggregate","Summary":"Enables or disables the query planner's use of partitionwise grouping or aggregation, which allows grouping or aggregation on partitioned tables to be performed separately for each partition. If the GROUP BY clause does not include the partition keys, only partial aggregation can be performed on a per-partition basis, and finalization must be performed later. With this setting enabled, the number of nodes whose memory usage is restricted by work_mem appearing in the final plan can increase linearly according to the number of partitions being scanned. This can result in a large increase in overall memory consumption during the execution of the query. Query planning also becomes significantly more expensive in terms of memory and CPU. The default value is off.","BodyHTML":"\u003cp\u003eEnables or disables the query planner\u0026#39;s use of partitionwise grouping or aggregation, which allows grouping or aggregation on partitioned tables to be performed separately for each partition. If the GROUP BY clause does not include the partition keys, only partial aggregation can be performed on a per-partition basis, and finalization must be performed later. With this setting enabled, the number of nodes whose memory usage is restricted by work_mem appearing in the final plan can increase linearly according to the number of partitions being scanned. This can result in a large increase in overall memory consumption during the execution of the query. Query planning also becomes significantly more expensive in terms of memory and CPU. The default value is off.\u003c/p\u003e","SourceRevision":"wiki-repair-20261023:dcbc2fa5f6cacfd3ffc7006c4b3385b13d5791b27af4550b85d5dd542f156a55","ContentHash":"f5b0c4c0de56ff1c786a805fbd8fa43b3bc14fee9ae1371ccdbf4569f9a51f1f","Payload":{"description":"Enables or disables the query planner's use of partitionwise grouping or aggregation, which allows grouping or aggregation on partitioned tables to be performed separately for each partition. If the GROUP BY clause does not include the partition keys, only partial aggregation can be performed on a per-partition basis, and finalization must be performed later. With this setting enabled, the number of nodes whose memory usage is restricted by work_mem appearing in the final plan can increase linearly according to the number of partitions being scanned. This can result in a large increase in overall memory consumption during the execution of the query. Query planning also becomes significantly more expensive in terms of memory and CPU. The default value is off."}},"RequestedLocale":"en","Fallback":false,"Versions":["11","12","13","14","15","16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
