Skip allocating hash table in EXPLAIN-only mode.
This is a backpatch of commit backpatched due to popular
demand. Backpatch to all supported versions.
Author: Alexey Bashtanov
Discussion:
@@ -2488,7 +2488,11 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
aggstate->hash_pergroup = pergroups;
find_hash_columns(aggstate);
+
+ /* Skip massive memory allocation if we are just doing EXPLAIN */
+ if (!(eflags & EXEC_FLAG_EXPLAIN_ONLY))
build_hash_table(aggstate);
+
aggstate->table_filled = false;
}
