The basic steps that SQL Server uses to process a single SELECT statement are:
- The parser scans the SELECT statement and breaks it into logical units such as keywords, expressions, operators, and identifiers.
- A query tree, sometimes called a sequence tree, is built describing the logical steps needed to transform the source data into the format needed by the result set.
- The query optimizer analyzes all the ways the source tables can be accessed and selects the series of steps that returns the results fastest while consuming fewer resources. The query tree is updated to record this exact series of steps, and the final, optimized version of the query tree is called the execution plan.
- The relational engine begins executing the execution plan. As steps that need data from the base tables are processed, the relational engine uses OLE DB to request that the storage engine pass up data from the rowsets requested from the relational engine.
- The relational engine processes the data returned from the storage engine into the format defined for the result set, and returns the result set to the client.