]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Skip allocating hash table in EXPLAIN-only mode.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 20 Nov 2020 12:41:14 +0000 (14:41 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 20 Nov 2020 12:57:51 +0000 (14:57 +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 a9e1fbb842e1f8bb8c2af037acc2a70f108f1519..41bfbb75d6f00853226a2de482ca4cbf15d5b9fc 100644 (file)
@@ -2254,7 +2254,10 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
 
        if (node->aggstrategy == AGG_HASHED)
        {
-               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;
                /* Compute the columns we actually need to hash on */
                aggstate->hash_needed = find_hash_columns(aggstate);