Simon Riggs wrote:
> IMHO we should have a single parameter which indicates how much planning
> time we consider acceptable for this query. e.g.
> optimization_level = 2 (default), varies 1-3
Couldn't the planner itself make a good guess if it should
keep trying based on the estimated cost?
if (the_best_plan_I_found_so_far_looks_like_itll_take_an_hour) keep_optimizing_for_a_few_minutes
if (the_best_plan_I_found_so_far_looks_like_itll_take_0.01ms) stop_planning_and_run_with_it
Or maybe as simple as something like
if (time_spent_planning >= cost_of_the_best_plan_found / 10) stop_optimizing.
If we wanted a GUC, perhaps make it that 10 in the expression above?