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
This commit is contained in:
Heikki Linnakangas 2020-11-20 14:41:14 +02:00
parent d01e37845c
commit 57b5d8484c
1 changed files with 5 additions and 1 deletions

View File

@ -2454,7 +2454,11 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
aggstate->hash_pergroup = pergroups;
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;
}