MS SQL Tracing/Monitoring Andrea Imrichova Monitoring SQL Server Monitor SQL server events to find possible performance issues Enables you to tune the database design to avoid performance issues Activity Monitor for real-time information and Data Collection for archived data Activity Monitor to obtain information about SQL Server processes and how these processes affect the current instance of SQL Server information about active user tasks, resource waits, data file I/O, and recent expensive queries Overview Pane % Processor Time: The percentage of elapsed time that the processor spends to execute non-idle threads for the instance across all CPUs. Waiting Tasks: The number of tasks that are waiting for processor, I/O, or memory resources. Database I/O: The transfer rate, in megabytes per second, of data from memory to disk, disk to memory, or disk to disk. Batch Requests/sec: The number of SQL Server batches that are received by the instance. Activity User Tasks Pane Session ID User Process (0 for system and 1 for user processes Login Database Task State (blank for runnable or sleeping, background, running suspended) Command Application Wait Time (ms) (0 if the task is not waiting) Wait Type Wait Resource Blocked By (ID of the session, that is blocking the task) Head Blocker (identifies the session, that causes the first blocking condition) Memory Use (KB) Host Name Workload Group (name of the Resource Governor workload group) Resource Waits Pane Wait Category Wait Time (ms/sec) for all tasks that are waiting for one or more resources in the wait category since the last update interval. Recent Wait Time (ms/sec) The weighted average wait time Average Waiter Count The number of tasks that are waiting. Cumulative Wait Time (sec) The total amount of time since SQL Server was last started on the instance Data File I/O Pane Database The name of the database. File Name The name of the files that belong to the database. MB/sec Read Recent read activity, in megabytes per second, for the database file. MB/sec Written Recent write activity, in megabytes per second, for the database file. Response Time (ms) Average response time, in milliseconds, of recent read-and-write activity to the database file. Recent Expensive Queries Pane - information about the most expensive queries that have been run on the instance over the last 30 seconds. sys.dm_exec_requests , sys.dm_exec_query_stats Query: The query statement that is being monitored. Executions/min: CPU (ms/sec): Physical Reads/sec: Logical Writes/sec: Logical Reads/sec: Average Duration (ms):. Plan Count: Data Collection runs constantly or on a user-defined schedule. The data collector stores the collected data in a relational database known as the management data warehouse. Enables to monitor archived data for performance issues Monitoring by Transact-SQL https://msdn.microsoft.com/enus/library/ms191511.aspx Resource Governor manage SQL Server workload and system resource consumption enables you to specify limits on the amount of CPU, physical IO, and memory that incoming application requests can use. workload workload is a set of similarly sized queries or requests that can, and should be, treated as a single entity not a requirement the more uniform the resource usage pattern of a workload is, the more benefit you get 3 concepts Resource pools. A resource pool, represents the physical resources of the server. Workload groups. . Classification. The Classification process assigns incoming sessions to a workload group based on the characteristics of the session. Resource pool 2 parts: 1. does not overlap with other pools, which enables minimum resource reservation 2. is shared with other pools, which supports maximum possible resource consumption MIN_CPU_PERCENT and MAX_CPU_PERCENT minimum and maximum guaranteed average CPU bandwidth If available CPU capacity, the workload uses it up to 100 percent The maximum value only applies when there is contention for CPU resources CAP_CPU_PERCENT hard cap limit on the CPU bandwidth for all requests in the resource pool CPU can use capacity above the value of MAX_CPU_PERCENT if it is available, but not above the value of CAP_CPU_PERCENT MIN_MEMORY_PERCENT MAX_MEMORY_PERCENT memory may remain in the given resource pool even when the pool does not have any requests in the workload groups belonging to this pool this memory will be unavailable even when there are no active requests MIN_IOPS_PER_VOLUME MAX_IOPS_PER_VOLUME minimum and maximum physical IO operations per second (IOPS) Some extreme cases of pool configuration All pools define minimums that in total represent 100 percent of the server resources. Maximums == minimums All pools have zero minimums. All the pools compete for available resources. Internal Pool is not alterable Resource consumption is not restricted Resource Governor allows the internal pool to pressure other pools even if it means the violation of limits set for the other pools Default Pool first predefined user pool cannot be created or dropped can be altered User-Defined Resource Pools Resource Governor provides DDL statements for creating, changing, and dropping resource pools. Workload Group container for session requests that have similar classification criteria Each workload group is in a resource pool Resource Governor classifier assigns the session to a specific workload group User-defined workload groups can be moved from one resource pool to another. Internal group user cannot change anything classified as an internal group Default group – automatic if no criteria/ nonexistent group or failure occurs DDL statements for creating, changing, and dropping workload groups. Create a Workload Group CREATE WORKLOAD GROUP groupAdhoc USING poolAdhoc; GO ALTER RESOURCE GOVERNOR RECONFIGURE; GO Governor Classifier Function is based on a set of user-written criteria contained in a function.