In SQL Server 2008, I would like to examine what is really going on behind the scenes when a query is executed. Can I somehow see the following?
- The number of (and maybe even the content of) the log records “produced” by a query.
- When the contents of the log is actually applied to the real data structures. For example:
- when are new rows actually added to the (clustering) index structure?
- and did the update/insertion imply a B-tree re-organization (and if so, how large part of that B-tree (how many pages) were affected in that)? Hmm, maybe I should have posted a separate question about this…
- Number of buffer misses/hits for each accessed table.
- The contents of the buffer (which, or how many, pages from the table are currently in the buffer)?
BTW: I considered splitting this question up in multiple smaller questions, but I guess they are somewhat quite related.
Here is a simple demo script to start your journey into learning about the SQL Server Internals. To see the individual actions of a query go to Paul Randal’s SQLSkills Blog.
Other posts on this blog will cover topics like DBCC PAGE which will allow you to see the contents of the PAGE and DBCC IND which will show you the allocation maps for tables/indexes. I recommend reading a copy of Microsoft SQL Server 2008 Internals which covers all of these topics in detail.
Transaction Log Records Demo Script
For the two Selects the misses are shown as the physical reads and read-ahead reads, these are the reads from disk into the buffer pool. The query engine then uses these pages and this is the logical reads. So for the io stats on the warm select it has no physical reads or read-ahead reads so all the pages required where already in the the buffer pool.
For the contents of the buffer pool the starting point is this DMV