aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeRecursiveunion.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2019-02-09 00:35:57 -0800
committerAndres Freund <andres@anarazel.de>2019-02-09 01:05:50 -0800
commit35afccaba6d0e0aa14e3d1f859e6d84e69aee2cc (patch)
tree2181cf72a9fda45f5dcf56158529face0a737a02 /src/backend/executor/nodeRecursiveunion.c
parent6455c65882474a48b6bde298bd04c18aa4e4b27f (diff)
downloadpostgresql-35afccaba6d0e0aa14e3d1f859e6d84e69aee2cc.tar.gz
postgresql-35afccaba6d0e0aa14e3d1f859e6d84e69aee2cc.zip
Reset, not recreate, execGrouping.c style hashtables.
This uses the facility added in the preceding commit to fix performance issues caused by rebuilding the hashtable (with its comparator expression being the most expensive bit), after every reset. That's especially important when the comparator is JIT compiled. Bug: #15592 #15486 Reported-By: Jakub Janeček, Dmitry Marakasov Author: Andres Freund Discussion: https://postgr.es/m/15486-05850f065da42931@postgresql.org https://postgr.es/m/20190114180423.ywhdg2iagzvh43we@alap3.anarazel.de Backpatch: 11, where I broke this in bf6c614a2f2c5
Diffstat (limited to 'src/backend/executor/nodeRecursiveunion.c')
-rw-r--r--src/backend/executor/nodeRecursiveunion.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/backend/executor/nodeRecursiveunion.c b/src/backend/executor/nodeRecursiveunion.c
index 6b3ea5afb31..791f1d6fd23 100644
--- a/src/backend/executor/nodeRecursiveunion.c
+++ b/src/backend/executor/nodeRecursiveunion.c
@@ -37,17 +37,18 @@ build_hash_table(RecursiveUnionState *rustate)
Assert(node->numCols > 0);
Assert(node->numGroups > 0);
- rustate->hashtable = BuildTupleHashTable(&rustate->ps,
- desc,
- node->numCols,
- node->dupColIdx,
- rustate->eqfuncoids,
- rustate->hashfunctions,
- node->numGroups,
- 0,
- rustate->tableContext,
- rustate->tempContext,
- false);
+ rustate->hashtable = BuildTupleHashTableExt(&rustate->ps,
+ desc,
+ node->numCols,
+ node->dupColIdx,
+ rustate->eqfuncoids,
+ rustate->hashfunctions,
+ node->numGroups,
+ 0,
+ rustate->ps.state->es_query_cxt,
+ rustate->tableContext,
+ rustate->tempContext,
+ false);
}
@@ -322,9 +323,9 @@ ExecReScanRecursiveUnion(RecursiveUnionState *node)
if (node->tableContext)
MemoryContextResetAndDeleteChildren(node->tableContext);
- /* And rebuild empty hashtable if needed */
+ /* Empty hashtable if needed */
if (plan->numCols > 0)
- build_hash_table(node);
+ ResetTupleHashTable(node->hashtable);
/* reset processing state */
node->recursing = false;