Introduction
When a query, a batch, or a stored procedure is submitted to SQL Server for execution for the first time, the query gets parsed and then compiled. The result of a compiled query is a query plan that is cached in the procedure cache. The procedure cache is a portion of memory that SQL Server allocates to cache its query plans.
When the query is executed, an execution plan with its execution context is derived from the cached query plan, in order to save time during query execution, because query compilation is quite a heavy and long process. If multiple users execute the same reusable query from multiple sessions, the same query plan is used with different execution contexts. Each execution plan has its own execution context (user and session-specific information) details with it. Eventually, these execution plans get executed. Subsequent execution of the same query can reuse the cached version of the plan, and the compilation step is skipped.
People often get confused between...