• GilaMonster (6/6/2012)


    Execution contexts aren't reused, they're specific to a single query's execution.

    Hmmm... Guess it's not true. From here:

    Suppose that a batch B contains an "if" statement. When B begins execution, an execution context for B is generated. Suppose that during this first execution, the "true" branch of the "if" is taken. Further, suppose that B was submitted again by another connection during the first execution. Because the only execution context existing at that moment was in use, a second execution context is generated and given to the second connection. Suppose that the second execution context takes the "false" branch of the "if". After both executions complete, B is submitted by a third connection. Supposing that the third execution of B chooses the "true" branch, the execution will complete slightly faster if SQL Server chose the first execution context of B for that connection rather than the second execution context.

    If, as you wrote, execution contexts was "structure-for-one-execution-only" no "slightly faster" execution can be possible in principle - agree?