30.06.2013 Views

SQL Server Execution Plans - Red Gate Software

SQL Server Execution Plans - Red Gate Software

SQL Server Execution Plans - Red Gate Software

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 4: Understanding More Complex Query <strong>Plans</strong><br />

…<br />

@AccountNumber NVARCHAR(15) = 'SPEEDCO0001',<br />

…<br />

Listing 4.10<br />

…the exact same query with the exact same execution plan will now UPDATE the data<br />

for values where the AccountNumber is equal to that passed through the parameter.<br />

Therefore, this plan, and the Merge operator, creates a single reusable plan for all the data<br />

manipulation operations it supports.<br />

Views<br />

A view is essentially just a "stored query," in other words, a logical way of representing<br />

data as if it were in a table, without actually creating a new table. The various uses of<br />

views are well documented (preventing certain columns from being selected, reducing<br />

complexity for end-users, and so on). Here, we will just focus on what happens within an<br />

execution plan when working with a view.<br />

Standard views<br />

The view, Sales.vIndividualCustomer, provides a summary of customer data,<br />

displaying information such as their name, email address, physical address and<br />

demographic information. A very simple query to get a specific customer would look<br />

something like Listing 4.11.<br />

SELECT *<br />

FROM Sales.vIndividualCustomer<br />

WHERE BusinessEntityId = 8743;<br />

Listing 4.11<br />

159

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!