Query Compilation and Optimization

Query compilation is the complete process from the submission of a query to its actual execution. There are many steps involved in query compilation—one of which is optimization. All T-SQL statements are compiled, but not all are optimized. Primarily, only the standard SQL Data Manipulation Language (DML) statements—SELECT, INSERT, UPDATE, and DELETE—require optimization. The other procedural constructs in T-SQL (IF, WHILE, local variables, and so on) are compiled as procedural logic but do not require optimization. DML statements are set-oriented requests that the Query Optimizer must translate into procedural code that can be executed efficiently to return the desired results.

Note

SQL Server also optimizes ...

Get Microsoft® SQL Server 2008 R2 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.