In addition to the interpretation of expressions (which back evaluation of WHERE clauses, target list projection, aggregates transition values etc) support compiling expressions to native code, using the infrastructure added in earlier commits.
To avoid duplicating a lot of code, only support emitting code for cases that are likely to be performance critical. For expression steps that aren't deemed that, use the existing interpreter.
The generated code isn't great - some architectural changes are required to address that. But this already yields a significant speedup for some analytics queries, particularly with WHERE clauses filtering a lot, or computing multiple aggregates.
Author: Andres Freund
2a0faed9d7 Add expression compilation support to LLVM JIT provider.
src/backend/executor/execExpr.c | 4 +
src/backend/executor/nodeValuesscan.c | 10 +
src/backend/jit/jit.c | 37 +
src/backend/jit/llvm/Makefile | 2 +-
src/backend/jit/llvm/llvmjit.c | 64 +
src/backend/jit/llvm/llvmjit_expr.c | 2637 +++++++++++++++++++++++++++++++++
src/backend/optimizer/plan/planner.c | 6 +
src/backend/utils/fmgr/fmgr.c | 94 +-
src/backend/utils/misc/guc.c | 11 +
src/include/fmgr.h | 2 +
src/include/jit/jit.h | 13 +
src/include/jit/llvmjit.h | 12 +
src/tools/pgindent/typedefs.list | 1 +
13 files changed, 2890 insertions(+), 3 deletions(-)