learningcomputer.com sql server 2008 – profiling and monitoring tools
TRANSCRIPT
Reasons to Monitor Troubleshoot problems, failed
maintenance jobs and isolate bottlenecks Improve SQL Server performance and
response time of your queries and reportsEstablish baseline performance for load
testingProactively look for problem areas if you
are the DBA or responsible for the server
Monitoring Tools in SQL ServerWindows
Task Manager Event ViewerPerformance Monitor
SQL Server Canned reports (server or database)Activity Monitor (SQL Server and Job) Logs (SQL Server and SQL Server Agent)TSQL And DMV (Dynamic Management
Views)SQL Server Profiler (Favorite)
Windows ToolsTask Manager
Quickest way to find information on CPU and MemoryPerformance tab gives a good visual of resourcesProcesses and Application tabs highlight all the
running programsEvent Viewer
Can be found under Administrative Tools (Control Panel)
Application tab gives you information on SQL Server Errors
Security tab has information on Failure AuditsDemo
Performance MonitorPerformance Monitor lets you get graphical
information on system countersYou can get real time data or from log filesIn Vista, Resource Overview gives you real
time data on CPU, Disk, Network Charts can be Line, Histogram or Report You can add multiple physical counters to
gather tons of information, some of these are specific to SQL Server
We will take a look at handful of important counters next
Performance Counters – Continued CPU
Processor:% Processor Time – Percent of CPU being utilized < 50% MEMORY
Available MBytes - Memory available to new processes, More is better
Pages/sec - Tells you how many times Virtual memory is being accessed
DISK% Disk Time – Similar to Processor Time > 90% is badAvg.Disk Queue Length – Shows # of I/O operations waiting >2 is
bad SQL Server
SQLServer:Access Methods - Full Scans / sec >1 or 2 is badSQL Server:Buffer Manager - Buffer cache hit ratio (Using cache) >
90 SQL Server:Locks - Average Wait Time, should be low
Canned Report Server Level
Server DashboardActivity - All SessionsPerformance – Top queries by average CPU
Database LevelDisk usage by Top tablesAll Transactions
Demo
Activity Monitor Where is it???? Took me a little bit to find this oneRMB on Server, select Activity MonitorNew look is broken down by Resource Area +
FilteringOverview section: Graphs and Charts on system
resourcesProcesses Section: Information on SPIDs. If you
right click, you can kill the process or launch Profiler directly
Resource Waits: Wait info on CPU, I/O, MemoryData File I/ORecent Expensive Queries – favorite section
Error Logs(SQL Server and SS Agent)General information on SQL Server activityBoth logs share the same GUIYou can filter by user, computer, date,
source and message One current and a number of Archive LogsArchived every time the service is restartedFile Location for logs is
C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Log\
Demo
TSQL And DMV’sTSQL
Sp_who2 and Sp_lockDBCC_INPUTBUFFER
DMVDMV’s are dynamic management views return server
state that can be used to monitor the health of a server instance
select * from sys.dm_os_sys_info has system level infoselect * from sys.dm_os_performance_counters will let
you get information on the performance countersMore information can be found at
http://msdn.microsoft.com/en-us/library/ms176083.aspx
Demo
ProfilerSQL Server Profiler is a graphical user interface to
SQL Trace for monitoring an instance of the Database Engine
You can capture and save data about each event to a file or table to analyze later
You can add Events class which is a type of event that can be traced e.g. Showplan XML
You can add a data column which is an attribute of an event classes captured in the trace e.g. Duration in milliseconds
Save the trace to a file or tableYou can use Out of the box templates or customize
them
Profiler – ContinuedDemo ScenarioI have created a user template called
Kash_template that I will use for the demoWe are looking for slow queries (duration >
100) in AdventureWorks2008 database I have setup two sessions to mimic activity:
One inserts data into SALES.CUSTOMER_ALL table and then updates it using a loop
The other one just browses data from SALES.CUSTOMER_ALL table using a loop
Both use the WAITFOR delay option