能否延长SQL Server Query Optimizer寻找最佳Query Plan的时长?
First, let's echo the key point you highlighted:
……optimizer并非旨在挑选最优execution plan,而是在一段固定时长的搜索后,找出当前所能得到的最优计划。
Your approach—using a database copy to let the optimizer take all the time it needs to generate the best possible query plan, then migrating that plan to production—is a solid line of thinking.
Unfortunately, as of right now, there’s no supported, direct way to modify how long SQL Server’s optimizer spends searching for an execution plan. The optimizer uses internal cost-based heuristics and thresholds to decide when to halt its search, and these settings aren’t exposed for manual adjustment.
You noted that related discussions touched on this direction but didn’t cover extending the optimization time, which matches the current state of SQL Server’s capabilities.
Since no feasible method exists to tweak this duration at the moment, marking your question as resolved is appropriate. If you later discover a way to adjust the optimizer's search window, be sure to update your post with your findings!
内容的提问来源于stack exchange,提问作者mud_punk

