Skip allocating hash table in EXPLAIN-only mode.
authorHeikki Linnakangas
Fri, 20 Nov 2020 12:41:14 +0000 (14:41 +0200)
committerHeikki Linnakangas
Fri, 20 Nov 2020 12:46:47 +0000 (14:46 +0200)
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

src/backend/executor/nodeAgg.c

index bdc17a5a64b2e0409850909a5429f5f6f25c0099..5ecd69cc954151165f7bf3970d73ab93edf52fad 100644 (file)
@@ -2488,7 +2488,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;
    }