diff options
author | David Rowley <drowley@postgresql.org> | 2024-12-11 13:47:16 +1300 |
---|---|---|
committer | David Rowley <drowley@postgresql.org> | 2024-12-11 13:47:16 +1300 |
commit | 0f5738202b812a976e8612c85399b52d16a0abb6 (patch) | |
tree | 9edf2821d761f7f42615573a45bf93f9ed64cf75 /src/include/executor/executor.h | |
parent | a43567483c617fb046c805b61964d5168c9a0553 (diff) | |
download | postgresql-0f5738202b812a976e8612c85399b52d16a0abb6.tar.gz postgresql-0f5738202b812a976e8612c85399b52d16a0abb6.zip |
Use ExprStates for hashing in GROUP BY and SubPlans
This speeds up obtaining hash values for GROUP BY and hashed SubPlans by
using the ExprState support for hashing, thus allowing JIT compilation for
obtaining hash values for these operations.
This, even without JIT compilation, has been shown to improve Hash
Aggregate performance in some cases by around 15% and hashed NOT IN
queries in one case by over 30%, however, real-world cases are likely to
see smaller gains as the test cases used were purposefully designed to
have high hashing overheads by keeping the hash table small to prevent
additional memory overheads that would be a factor when working with large
hash tables.
In passing, fix a hypothetical bug in ExecBuildHash32Expr() so that the
initial value is stored directly in the ExprState's result field if
there are no expressions to hash. None of the current users of this
function use an initial value, so the bug is only hypothetical.
Reviewed-by: Andrei Lepikhov <lepihov@gmail.com>
Discussion: https://postgr.es/m/CAApHDvpYSO3kc9UryMevWqthTBrxgfd9djiAjKHMPUSQeX9vdQ@mail.gmail.com
Diffstat (limited to 'src/include/executor/executor.h')
-rw-r--r-- | src/include/executor/executor.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index b8433eabc1f..494ec4f2e5d 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -159,7 +159,7 @@ extern TupleHashEntry LookupTupleHashEntryHash(TupleHashTable hashtable, extern TupleHashEntry FindTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot, ExprState *eqcomp, - FmgrInfo *hashfunctions); + ExprState *hashexpr); extern void ResetTupleHashTable(TupleHashTable hashtable); /* @@ -288,6 +288,14 @@ extern ExprState *ExecInitCheck(List *qual, PlanState *parent); extern List *ExecInitExprList(List *nodes, PlanState *parent); extern ExprState *ExecBuildAggTrans(AggState *aggstate, struct AggStatePerPhaseData *phase, bool doSort, bool doHash, bool nullcheck); +extern ExprState *ExecBuildHash32FromAttrs(TupleDesc desc, + const TupleTableSlotOps *ops, + FmgrInfo *hashfunctions, + Oid *collations, + int numCols, + AttrNumber *keyColIdx, + PlanState *parent, + uint32 init_value); extern ExprState *ExecBuildHash32Expr(TupleDesc desc, const TupleTableSlotOps *ops, const Oid *hashfunc_oids, |