{"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"}],"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"],"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":"english-manuals:30d67b102ec3fadfea237e2a83dc4b97f6de8a47482b53c4a107b0a7adc2440d","unit":"","vartype":"bool"}},"Definition":{"Collection":"guc","Key":"enable_partitionwise_aggregate","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"enable_partitionwise_aggregate","SourceRevision":"english-manuals:30d67b102ec3fadfea237e2a83dc4b97f6de8a47482b53c4a107b0a7adc2440d","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.","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","unit":null,"vartype":"bool"},"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":"english-manuals:30d67b102ec3fadfea237e2a83dc4b97f6de8a47482b53c4a107b0a7adc2440d","ContentHash":"38d7641d1e264867ba3e7c1f8ac466f9aa97863dd030f324c9dbad9b857b9e00","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":"zh-Hans","Fallback":true,"Versions":["11","12","13","14","15","16","17","18","19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
