In 02bf035 (#16), estimate_path_cost_size() was tweaked to estimate a lower cost so as to prevent the MIN/MAX optimization that Postgres creates from taking priority. This works well-enough, but it might be better to instead search through the paths in the root node, find any remote min/max optimization paths, and increase their costs, to convince the planner not to use them. This seems more honest, since we don't want the optimization to be pushed down to ClickHouse, and would allow more accurate costing to be implemented in estimate_path_cost_size().
In 02bf035 (#16),
estimate_path_cost_size()was tweaked to estimate a lower cost so as to prevent the MIN/MAX optimization that Postgres creates from taking priority. This works well-enough, but it might be better to instead search through the paths in the root node, find any remotemin/maxoptimization paths, and increase their costs, to convince the planner not to use them. This seems more honest, since we don't want the optimization to be pushed down to ClickHouse, and would allow more accurate costing to be implemented inestimate_path_cost_size().