Here are the 4 basic steps all queries go through:
1. Parsing: The query is examined by SQL Server to syntax errors, invalid column and table names etc.. It outputs a parse tree for the next step to process.
2. Algebrizing: This is often called the “binding” stage as SQL Server now resolves all name references, type derivation, aggregate binding and group binding on the parse tree passed to it. It then outputs a query tree for the next step.
3. Optimizing: This step takes the query tree and checks the cache for a valid plan to use. If not, it then continues to determine if it is a trivial plan. If not, it simplifies the query (normalizing the query tree). If the plan is cheap enough it will then put the compiled plan in the plan cache and passes it off to the plan executor.
4. Executing: Here the plan is executed by the plan executor in SQL Server and the results return to the client.
(taken from Wrox’s “Professional SQL Server 2012 Internals and Troubleshooting”)
Views – 2085