From: Heikki Linnakangas Date: Fri, 20 Nov 2020 12:41:14 +0000 (+0200) Subject: Skip allocating hash table in EXPLAIN-only mode. X-Git-Tag: REL_10_16~78 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1dbe627fd6bf889ad117a706ff474f7382a66465;p=thirdparty%2Fpostgresql.git Skip allocating hash table in EXPLAIN-only mode. This is a backpatch of commit 2cccb627f1, backpatched due to popular demand. Backpatch to all supported versions. Author: Alexey Bashtanov Discussion: https://www.postgresql.org/message-id/36823f65-050d-ae24-aa4d-a37726998240%40imap.cc --- diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index 1dcd8e19ed2..8f9d588e5a5 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -3073,7 +3073,11 @@ ExecInitAgg(Agg *node, EState *estate, int eflags) aggstate->hash_pergroup = palloc0(sizeof(AggStatePerGroup) * numHashes); find_hash_columns(aggstate); - build_hash_table(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; }