diff options
author | Andres Freund <andres@anarazel.de> | 2018-03-20 02:20:46 -0700 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2018-03-22 14:45:59 -0700 |
commit | 2a0faed9d7028e3830998bd6ca900be651274e27 (patch) | |
tree | 0ab54ad8ac5c5d97d7a4dcee4c2d99c7959af2f6 /src/backend/executor/nodeValuesscan.c | |
parent | 7ced1d1247286399df53823eb76cacaf6d7fdb22 (diff) | |
download | postgresql-2a0faed9d7028e3830998bd6ca900be651274e27.tar.gz postgresql-2a0faed9d7028e3830998bd6ca900be651274e27.zip |
Add expression compilation support to LLVM JIT provider.
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
Tested-By: Thomas Munro
Discussion: https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.de
Disable JITing for VALUES() nodes.
VALUES() nodes are only ever executed once. This is primarily helpful
for debugging, when forcing JITing even for cheap queries.
Author: Andres Freund
Discussion: https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.de
Diffstat (limited to 'src/backend/executor/nodeValuesscan.c')
-rw-r--r-- | src/backend/executor/nodeValuesscan.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/backend/executor/nodeValuesscan.c b/src/backend/executor/nodeValuesscan.c index 63b7e7ef5b8..6ec087b9688 100644 --- a/src/backend/executor/nodeValuesscan.c +++ b/src/backend/executor/nodeValuesscan.c @@ -25,6 +25,7 @@ #include "executor/executor.h" #include "executor/nodeValuesscan.h" +#include "jit/jit.h" #include "utils/expandeddatum.h" @@ -98,6 +99,7 @@ ValuesNext(ValuesScanState *node) bool *isnull; ListCell *lc; int resind; + int saved_jit_flags; /* * Get rid of any prior cycle's leftovers. We use ReScanExprContext @@ -128,7 +130,15 @@ ValuesNext(ValuesScanState *node) oldsubplans = node->ss.ps.subPlan; node->ss.ps.subPlan = NIL; + /* + * As the expressions are only ever used once, disable JIT for + * them. This is worthwhile because it's common to insert significant + * amounts of data via VALUES(). + */ + saved_jit_flags = econtext->ecxt_estate->es_jit_flags; + econtext->ecxt_estate->es_jit_flags = PGJIT_NONE; exprstatelist = ExecInitExprList(exprlist, &node->ss.ps); + econtext->ecxt_estate->es_jit_flags = saved_jit_flags; node->ss.ps.subPlan = oldsubplans; |