inited JIT support for plan generated by ORCA
@@ -290,6 +290,8 @@ static split_rollup_data *make_new_rollups_for_hash_grouping_set(PlannerInfo *ro
Path *path,
grouping_sets_data *gd);
+static void compute_jit_flags(PlannedStmt* pstmt);
+
/*****************************************************************************
*
* Query optimizer entry point
@@ -370,6 +372,12 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
result = optimize_query(parse, cursorOptions, boundParams);
+ /* decide jit state */
+ if (result)
+ {
+ compute_jit_flags(result);
+ }
+
if (gp_log_optimization_time)
{
INSTR_TIME_SET_CURRENT(endtime);
@@ -737,30 +745,8 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
result->stmt_location = parse->stmt_location;
result->stmt_len = parse->stmt_len;
- result->jitFlags = PGJIT_NONE;
- if (jit_enabled && jit_above_cost >= 0 &&
- top_plan->total_cost > jit_above_cost)
- {
- result->jitFlags |= PGJIT_PERFORM;
-
- /*
- * Decide how much effort should be put into generating better code.
- */
- if (jit_optimize_above_cost >= 0 &&
- top_plan->total_cost > jit_optimize_above_cost)
- result->jitFlags |= PGJIT_OPT3;
- if (jit_inline_above_cost >= 0 &&
- top_plan->total_cost > jit_inline_above_cost)
- result->jitFlags |= PGJIT_INLINE;
-
- /*
- * Decide which operations should be JITed.
- */
- if (jit_expressions)
- result->jitFlags |= PGJIT_EXPR;
- if (jit_tuple_deforming)
- result->jitFlags |= PGJIT_DEFORM;
- }
+ /* GPDB: JIT flags are set in wrapper function */
+ compute_jit_flags(result);
if (glob->partition_directory != NULL)
DestroyPartitionDirectory(glob->partition_directory);
@@ -8601,3 +8587,40 @@ make_new_rollups_for_hash_grouping_set(PlannerInfo *root,
return srd;
}
+
+/*
+ * GPDB: This is moved from standard_planner(), so that it can be used by both
+ * planner and ORCA. Please move any future code added to standard_planner() too.
+ *
+ * Decide JIT settings for the given plan and record them in PlannedStmt.jitFlags.
+ */
+static void compute_jit_flags(PlannedStmt* pstmt)
+{
+ Plan* top_plan = pstmt->planTree;
+
+ pstmt->jitFlags = PGJIT_NONE;
+
+ if (jit_enabled && jit_above_cost >= 0 &&
+ top_plan->total_cost > jit_above_cost)
+ {
+ pstmt->jitFlags |= PGJIT_PERFORM;
+
+ /*
+ * Decide how much effort should be put into generating better code.
+ */
+ if (jit_optimize_above_cost >= 0 &&
+ top_plan->total_cost > jit_optimize_above_cost)
+ pstmt->jitFlags |= PGJIT_OPT3;
+ if (jit_inline_above_cost >= 0 &&
+ top_plan->total_cost > jit_inline_above_cost)
+ pstmt->jitFlags |= PGJIT_INLINE;
+
+ /*
+ * Decide which operations should be JITed.
+ */
+ if (jit_expressions)
+ pstmt->jitFlags |= PGJIT_EXPR;
+ if (jit_tuple_deforming)
+ pstmt->jitFlags |= PGJIT_DEFORM;
+ }
+}
