Presentation is loading. Please wait.

Presentation is loading. Please wait.

Kris Hokanson That’s bad mmmkay! …Or, how to know when your SQL Server isn’t working as well as it could.

Similar presentations


Presentation on theme: "Kris Hokanson That’s bad mmmkay! …Or, how to know when your SQL Server isn’t working as well as it could."— Presentation transcript:

1 Kris Hokanson That’s bad mmmkay! …Or, how to know when your SQL Server isn’t working as well as it could

2 Who is Kris Hokanson? Owner and SQL guru at Variable SQL Solutions
SQL Server admin since 1998 and SQL 7 Projects range from general database administration and database performance improvement to BI process design using SSIS & SSRS 2 | Random Acts of Senseless Databasing

3 Why are we here? Surprising number of people just don’t know
Random Acts of Senseless Databasing Why are we here? Surprising number of people just don’t know Set expectations from your server Is something wrong? How is it wrong? Real-world scenarios This presentation was born out of frustration of going into a new environment and nobody else noticing that servers or processes were running poorly. Know how your server should be performing on a regular basis so that when it’s not performing that way, it’s easy to identify. Don’t trust users to tell you when things aren’t running properly. 3 |

4 Setting Expectations Performance monitoring tools
Random Acts of Senseless Databasing Setting Expectations Performance monitoring tools Perfmon, Idera DM, Red-Gat SQL Monitor, Quest Foglight, etc Require proper setup Establish server baseline (know your servers) Helpful when troubleshooting or identifying when something’s wrong Active monitoring of a server is imperative for proactive management and thorough troubleshooting. I prefer free solutions such as Perfmon for starters but as your server count grows it becomes more important to have a dedicated monitoring tool for better alerting and analysis. I hold onto perfmon data as long as possible since it’s useful for identifying trends and histories. Can be easily imported into SQL Server for summarization and the original files compress very well for archival purposes.

5 Setting Expectations Important Metrics
Memory – Available MBytes Physical Disk Avg. Disk sec/Read/Write Disk Reads/Writes/sec Processor – % Processor Time SQLServer: General Statistics – User Connections SQLServer: SQL Statistics – Batch Requests/sec SQLServer: SQL Statistics – Compilations/sec SQL Server:Buffer Manager - Page life expectancy

6

7 Setting Expectations Perfmon demo

8 Setting Expectations Further Reading
Brent Ozar - SQL Server Perfmon (Performance Monitor) Best Practices Jonathan Kehayias - Essential Perfmon Counters

9 Is Something Wrong? Does it take longer than usual?
Does a process take hours/minutes instead of minutes/seconds? What do the DMVs say? What does Brent Ozar say? If you regularly connect to a server with SSMS or log in through RDP and it typically takes a couple of seconds to open SSMS but suddenly it’s taking 20, maybe the server is working harder than it needs to. If you’re running a report or process that’s only processing a few hundred thousand rows then there’s typically no reason it should take several minutes. SQL Server can handle millions of rows with relative ease (read a few seconds) if queries are written properly. Brent Ozar Unlimited’s sp_blitz scripts are better than anything I’ve got but they all use the magic DMVs to get their results. Random Acts of Senseless Databasing

10 Is Something Wrong Important DMVs
sys.dm_exec_sessions sys.dm_exec_requests sys.dm_exec_connections sys.dm_exec_sql_text sys.dm_exec_query_stats sys.dm_exec_cached_plans sys.dm_os_wait_stats

11 Is Something Wrong Further Reading
Gregory A. Larsen - Finding the Worst Performing T-SQL Statements on an Instance Paul Randal - Wait statistics, or please tell me where it hurts

12 How Is It Wrong? Extended Events Execution Plans Bigger picture
Hundreds of different events, only a few are important Execution Plans Detailed explanation of a query Shows where all the work is done Useful to include Set Statistics IO & Time

13 How Is It Wrong – Extended Events
Different events include different fields (actions) Extended Event viewer in SSMS is  Read resulting XML files into SQL tables for analysis using t-sql Can easily aggregate reads/writes/durations Some of the more important ones are sp_statement_completed, sql_statement_completed, sql_batch_completed Important fields are client name, client_hostname, database_id, database_name, nt_username. Fields that are automatically included and are most useful for performance analysis include duration, logical_reads, physical_reads, writes

14 Extended event setup demo
How Is It Wrong – Extended Events Extended event setup demo

15 How Is It Wrong – Execution Plans
Identify discrete operations in a query Provide detailed breakdown at each step Graphically represent data flow through the query Rich with clues for improvement

16 How is it Wrong – Execution Plans

17 How Is It Wrong Further Reading
Jeremiah Peschka - Collecting Detailed Performance Measurements with Extended Events Tim Ford - SQL Server Query Execution Plans in SQL Server Management Studio Tim Cullen - Getting IO and time statistics for SQL Server queries

18 Real-World Example Nested Views

19 Real-World Example Cursors

20 Questions/comments/snide remarks

21 Thank you! Kris Hokanson


Download ppt "Kris Hokanson That’s bad mmmkay! …Or, how to know when your SQL Server isn’t working as well as it could."

Similar presentations


Ads by Google