On Thu, Aug 3, 2023 at 5:22 AM Jian Guo <gj...@vmware.com> wrote: > I have write an initial patch to retire the disable_cost GUC, which labeled a > flag on the Path struct instead of adding up a big cost which is hard to > estimate. Though it involved in tons of plan changes in regression tests, I > have tested on some simple test cases such as eagerly generate a two-stage > agg plans and it worked. Could someone help to review?
I took a look at this patch today. I believe that overall this may well be an approach worth pursuing. However, more work is going to be needed. Here are some comments: 1. You stated that it changes lots of plans in the regression tests, but you haven't provided any sort of analysis of why those plans changed. I'm kind of surprised that there would be "tons" of plan changes. You (or someone) should look into why that's happening. 2. The change to compare_path_costs_fuzzily() seems incorrect to me. When path1->is_disabled && path2->is_disabled, costs should be compared just as they are when neither path is disabled. Instead, the patch treats any two such paths as having equal cost. That seems catastrophically bad. Maybe it accounts for some of those plan changes, although that would only be true if those plans were created while using some disabling GUC. 3. Instead of adding is_disabled at the end of the Path structure, I suggest adding it between param_info and parallel_aware. I think if you do that, the space used by the new field will use up padding bytes that are currently included in the struct, instead of making it longer. 4. A critical issue for any patch of this type is performance. This concern was raised earlier on this thread, but your path doesn't address it. There's no performance analysis or benchmarking included in your email. One idea that I have is to write the cost-comparison test like this: if (unlikely(path1->is_disabled || path2->is_disabled)) { if (!path1->is_disabled) return COSTS_BETTER1; if (!path2->is_disabled) return COSTS_BETTER2; /* if both disabled, fall through */ } I'm not sure that would be enough to prevent the patch from adding noticeably to the cost of path comparison, but maybe it would help. 5. The patch changes only compare_path_costs_fuzzily() but I wonder whether compare_path_costs() and compare_fractional_path_costs() need similar surgery. Whether they do or don't, there should likely be some comments explaining the situation. 6. In fact, the patch changes no comments at all, anywhere. I'm not sure how many comment changes a patch like this needs to make, but the answer definitely isn't "none". 7. The patch doesn't actually remove disable_cost. I guess it should. 8. When you submit a patch, it's a good idea to also add it on commitfest.postgresql.org. It doesn't look like that was done in this case. -- Robert Haas EDB: http://www.enterprisedb.com