From 356687bd825e5ca7230d43c1bffe7a59ad2e77bd Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Sat, 9 Feb 2019 00:35:57 -0800 Subject: Reset, not recreate, execGrouping.c style hashtables. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/backend/executor/nodeSetOp.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src/backend/executor/nodeSetOp.c') diff --git a/src/backend/executor/nodeSetOp.c b/src/backend/executor/nodeSetOp.c index 5d8c8b8b029..26aeaee0838 100644 --- a/src/backend/executor/nodeSetOp.c +++ b/src/backend/executor/nodeSetOp.c @@ -126,17 +126,18 @@ build_hash_table(SetOpState *setopstate) Assert(node->strategy == SETOP_HASHED); Assert(node->numGroups > 0); - setopstate->hashtable = BuildTupleHashTable(&setopstate->ps, - desc, - node->numCols, - node->dupColIdx, - setopstate->eqfuncoids, - setopstate->hashfunctions, - node->numGroups, - 0, - setopstate->tableContext, - econtext->ecxt_per_tuple_memory, - false); + setopstate->hashtable = BuildTupleHashTableExt(&setopstate->ps, + desc, + node->numCols, + node->dupColIdx, + setopstate->eqfuncoids, + setopstate->hashfunctions, + node->numGroups, + 0, + setopstate->ps.state->es_query_cxt, + setopstate->tableContext, + econtext->ecxt_per_tuple_memory, + false); } /* @@ -635,7 +636,7 @@ ExecReScanSetOp(SetOpState *node) /* And rebuild empty hashtable if needed */ if (((SetOp *) node->ps.plan)->strategy == SETOP_HASHED) { - build_hash_table(node); + ResetTupleHashTable(node->hashtable); node->table_filled = false; } -- cgit v1.2.3