Chapter 2: Graphical Execution Plans

December 23, 2008 at 7:58 am (TSQL)

Simple-Talk has posted Chapter 2 of the book online. The one thing missing from the chapter (and the book for that matter) that you really need is sys.dm_exec_query_plans. That DMV is a must have for working with execution plans.


  1. CK said,

    Hey Grant,

    I am reading through this book right now and I think it is great. I have a question on chapter 4. Does a query using APPLY really count as a derived table? When you use an APPLY operator you are always tying the outer query to the inner query or function. Just like a correlated subquery it will be executed for each row of the outer expression. I always thought of a derived table as something that could be excuted in isolation and treated as its own table. I hope I am not getting caught up in semantics, just looking for a clarification.



  2. scarydba said,

    Believe it or not, I need to back & read what I wrote. I won’t leave you hanging on this, I just need to review what I said to be sure of the context.

  3. scarydba said,

    Morning. I re-read it and now I remember.

    Yeah, the internals of the APPLY operator are basically a similar construct to the derived table. Clearly, not identical.

    I also looked it up in Itzik Ben-Gan’s outstanding T-SQL Querying book. He refers to the APPLY operation as a table expression too. I checked BOL. It too refers to the APPLY construct as a table expression.

    It is a correlation process, but it’s a correlation between tables, effectively, not between a row and a select statement.

    Hopefully that clarifies things a bit.

  4. CK said,

    Grant, thanks for explaining. I had to force myself to overcome the slight reluctance to grasping it as a table expression. I have the T-SQL querying book as well and it definately lists it as a table expression. I went back and looked at your example in chapter 4 (Most recent Price History for a Product). That is a great example of how it behaves as a table expression.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: