0

I have tried to get the estimated execution plan in SQL Server Management Studio 2008.

As far as I know the it always returns the best query plan, as an execution plan. Right now I'm working on a research and I need to get all possible query plans for a specific query from SQL Server, and force the engine to execute one of those query plans which is determined as a better query plan using my algorithm, as an execution plan.

Does anybody know how can I get all possible query plans from SQL Server for a specific query and force it to execute one of those as a execution plan ?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
diba6122
  • 31
  • 1
  • 7
  • 1
    For any given query, I don't know how you're ever going to know that you've exhausted every possible query plan. You can force certain behaviors by messing with statistics, using index hints, using join hints, etc. But more importantly: why do you think your algorithm to pick the optimal plan will be better than SQL Server's? If you find a case where you are better at picking the plan than SQL Server is, you'll want to report that with a full repro on [Connect](http://connect.microsoft.com/sql/), because it's something that optimizer team will likely want to investigate. – Aaron Bertrand Nov 26 '12 at 18:24
  • ...though they're not likely going to port any such fixes back to SQL Server 2008... – Aaron Bertrand Nov 26 '12 at 18:24

0 Answers0