SQL Exec Stats, Copyright © 2006-2012 Elemental Inc. All rights reserved.
Read Me, Intro, Main, General, Databases, File IO, Tables, Indexes, Exec Stats, Stored Procs, Dist Stats, Appendix
SQL Exec Stats Readme, www.qdpma.com, jchang6@yahoo.com
Build 2012-09-07
New FeaturesThis is an intermediate build.
Many of the try catch blocks have been disabled to force an error
The basic data structures are being changed,
so backward compatability cannot be maintained.
The current version cannot read files from previous ExecStats.
It is possible to use an older version to generate the sqlplan files.
Then use the current version to parse the plan files.
Modes:
Originally, I intended to provide many modes,
but after extensive field use, I have been focused on 2 modes:
1) Execution stat froms sys.dm_exec_query_stats
grouped by sql_handle and statement_start,
2) Estimated execution plans for all stored procedures in selected databases.
Other modes that I intend to support (but not currently getting tested with new features) are:
a) Estimated or Actual plans with SQL from a query specified in the config file
b) Execution plans from a trace file.
(2010-11-23) The dm_exec_procedure_stats option is disabled while work on new features is in progress. The dm_exec_query_stats option grouped by plan handle is disabled pending review of functionality.
Generate Plans for All Stored Procedure
Check the radio button SP fn (functions not currently implemented)
Sub-procedure plan info is removed, so only actual SQL in a given
procedure is displayed.
Function SQL cannot be removed(?)
This will only get stored procedures from the last database check,
so this is really a single database option for now.
Parse existing Sqlplan files
Right click the Connect Button until the text is SQL Plans
click again, select the first file in a directory.
An index usage list is generated as well.
Multi-Database
Click the '...' button to the right of the databases drop box to list all databases
Not all UI is consistent with multi-database functionality.
This will be corrected over time.
To Do
Collecting too much data can crash the program. Currently there is nothing that checks for oversize data, other than overly frequent calls to the garbage collector. I suggest not collecting on too many databases together, with attention to tables with a very large number of indexes and statistics. Later versions will check for this..
Views to be implemented
Activity Monitor in SQL Server 2008 merges dm_exec_query_stats with dm_exec_requests to include currently running queries. I might do the same as time permits.
Bug fixes in 2009:
Additional Notes
The index views sys.dm_db_index_operational_stats
and sys.dm_db_index_physical_stats
are of interest, but can be resource consuming to run.
These might be more appropriate for a general index maintenance tool.
So there are no immediate plans to include the index views in ExecStats.
sys.dm_db_file_space_usage is for tempdb only
sys.dm_db_index_operational_stats (
{ database_id | NULL | 0 | DEFAULT }
, { object_id | NULL | 0 | DEFAULT }
, { index_id | 0 | NULL | -1 | DEFAULT }
, { partition_number | NULL | 0 | DEFAULT } )
Returns current low-level I/O, locking, latching, and access method activity
for each partition of a table or index in the database.
sys.dm_db_index_physical_stats (
{ database_id | NULL | 0 | DEFAULT }
, { object_id | NULL | 0 | DEFAULT }
, { index_id | NULL | 0 | -1 | DEFAULT }
, { partition_number | NULL | 0 | DEFAULT }
, { mode | NULL | DEFAULT } )
The view sys.dm_os_buffer_descriptors
provides detailed information on memory allocation by database, file, numa node, and type.
Some useful queries based on this view are below.
On high-end systems with very large amounts of memory, and very many databases,
this query can be expensive to run. I may include an option for this later.
-- should implement?
SELECT *
FROM
sys.dm_os_nodes
-- 14 col
SELECT *
FROM
sys.dm_os_schedulers
-- by numa_node
SELECT *
FROM (
  SELECT database_id,
file_id, numa_node, row_count
  FROM
sys.dm_os_buffer_descriptors
WITH(NOLOCK
)
 ) p
PIVOT
(COUNT(row_count)
FOR numa_node
IN
([0],[1],[2],
[3],[4],[5],[6],
[7]))
AS pvt
ORDER BY database_id,
file_id
-- by page_type
SELECT
DB_NAME(database_id),
*
FROM ( -- p
 
SELECT
database_id, file_id,
page_type, row_count
 
FROM
sys.dm_os_buffer_descriptors
WITH(NOLOCK)
) p
PIVOT
( COUNT(row_count)
FOR page_type IN
([DATA_PAGE],[INDEX_PAGE],[TEXT_MIX_PAGE])
) AS pvt
ORDER BY database_id,
file_id
/* GAM_PAGE, IAM_PAGE, SGAM_PAGE, PFS_PAGE, TEXT_TREE_PAGE, DIFF_MAP_PAGE, BOOT_PAGE*/