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

Slides:



Advertisements
Similar presentations
Presented by Brad Gall Using BI Techniques for Database Statistics.
Advertisements

Challenge for all the Seniors (DBAs) QuestionAreaYou (Today) You (6 Months) You (1 Year) 1Design Tables 2Write Queries 3Deploy Changes 4Tune Queries 5Monitor.
Automating Common DBA Tasks
The Essentials: DMV’s and T-SQL for the DBA Rocky Mountain Tech Tri-Fecta.
11 MONITORING MICROSOFT WINDOWS SERVER 2003 Chapter 3.
Chapter 9 Overview  Reasons to monitor SQL Server  Performance Monitoring and Tuning  Tools for Monitoring SQL Server  Common Monitoring and Tuning.
Module 18 Monitoring SQL Server 2008 R2. Module Overview Monitoring Activity Capturing and Managing Performance Data Analyzing Collected Performance Data.
Key Concepts About Performance Factors Affecting SQL Performance SQL Performance Tuning Methodologies SQL Performance Tuning Tools 1.
Developers of a suite of products to help you monitor and optimize Windows/SQL Server performance o Performance Advisor – awareness and control over Windows.
Module 7 Reading SQL Server® 2008 R2 Execution Plans.
Informix IDS Administration with the New Server Studio 4.0 By Lester Knutsen My experience with the beta of Server Studio and the new Informix database.
Learningcomputer.com SQL Server 2008 – Administration, Maintenance and Job Automation.
Learningcomputer.com SQL Server 2008 – Profiling and Monitoring Tools.
© 2008 Quest Software, Inc. ALL RIGHTS RESERVED. Perfmon and Profiler 101.
SQLRX – SQL Server Administration – Tips From the Trenches SQL Server Administration – Tips From the Trenches Troubleshooting Reports of Sudden Slowdowns.
MISSION CRITICAL COMPUTING Siebel Database Considerations.
Diagnosing Performance with Wait Statistics Robert L Davis Principal Database
Copyright Sammamish Software Services All rights reserved. 1 Prog 140  SQL Server Performance Monitoring and Tuning.
Linkedin: dennisegraham Dennis E Graham Reporting For SQL Health.
SQL Advanced Monitoring Using DMV, Extended Events and Service Broker Javier Villegas – DBA | MCP | MCTS.
You Inherited a Database Now What? What you should immediately check and start monitoring for. Tim Radney, Senior DBA for a top 40 US Bank President of.
No more waiting. Sponsors About me  Database Technology Specialist  MVP  Blogger  Author 3
Fixing Page Life Expectancy Steve Hood Blog: SimpleSQLServer.com.
MANAGEMENT DATA WAREHOUSE AND DATA COLLECTOR Ian Lanham.
3 Methods to End the Madness
An introduction to Wait Statistics
You Inherited a Database Now What?
A big party is being held to honor relational database systems and their impact on modern society. Outside the venue, the host awaits the guests. The.
Performance Management
Troubleshooting SQL Server high CPU usage
Data Virtualization Tutorial: Introduction to SQL Script
Execution Planning for Success
SQL Server Data Collector From Every Angle
Building a Performance Monitoring System using XEvents and DMVs
Benchmarking the forgotten Role of Performance Tuning
Query Performance Tuning: Start to Finish
Building a Performance Monitoring System using XEvents and DMVs
Using Extended Events to Diagnose Application Issues
SQL Server Monitoring Overview
MONITORING MICROSOFT WINDOWS SERVER 2003
Where to Start, What You Need
Microsoft Dumps Question Answer - Dumps4download
Root Cause Analysis with DMVs
Simplifying XEvents Management with dbatools
SQL Server May Let You Do It, But it Doesn’t Mean You Should
Performance Monitoring Using Extended Events, DMVs & Query Store
Building a Performance Monitoring System using XEvents and DMVs
Discover Your Database From The Inside!
Troubleshooting SQL Server Basics
Performance Tuning for Mere Mortals Part II
Agenda Database Development – Best Practices Why Performance Matters ?
Performance Tuning for Mere Mortals Part II
Targeting Wait Statistics with Extended Events
Dynamic Management Views a practical overview!
SQL Server Performance Tuning
Moving from SQL Profiler to xEvents
Four Rules For Columnstore Query Performance
You Inherited a Database Now What?
Dynamic Management Views a practical overview!
Analyzing Performance Problems Using XEvents, DMVs & Query Store
Performance And Scalability In Oracle9i And SQL Server 2000
Jean Joseph DBA/Developer
Building a Performance Monitoring System using XEvents and DMVs
Jean Joseph DBA\DEVELOPER
The Force Within Management Data Warehouse
Using wait stats to determine why my server is slow
WHAT ARE THE ADVANTAGES AND CHALLENGES OF MICROSOFT SQL SERVER.
Advanced Database Topics
Analyzing Performance Problems Using XEvents, DMVs & Query Store
The DBA Quit and now you’re it:
Presentation transcript:

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

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 Email: Kris@variablesql.com 2 | Random Acts of Senseless Databasing

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 |

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.

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

Setting Expectations Perfmon demo

Setting Expectations Further Reading Brent Ozar - SQL Server Perfmon (Performance Monitor) Best Practices https://www.brentozar.com/archive/2006/12/dba-101-using-perfmon-for-sql-performance-tuning/ Jonathan Kehayias - Essential Perfmon Counters https://www.sqlskills.com/blogs/jonathan/the-accidental-dba-day-21-of-30-essential-perfmon-counters/

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

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

Is Something Wrong Further Reading Gregory A. Larsen - Finding the Worst Performing T-SQL Statements on an Instance https://www.databasejournal.com/features/mssql/article.php/3802936/Finding-the-Worst-Performing-T-SQL-Statements-on-an-Instance.htm Paul Randal - Wait statistics, or please tell me where it hurts https://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/

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

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

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

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

How is it Wrong – Execution Plans

How Is It Wrong Further Reading Jeremiah Peschka - Collecting Detailed Performance Measurements with Extended Events https://www.brentozar.com/archive/2014/04/collecting-detailed-performance-measurements-extended-events/ Tim Ford - SQL Server Query Execution Plans in SQL Server Management Studio https://www.mssqltips.com/sqlservertip/1856/sql-server-query-execution-plans-in-sql-server-management-studio/ Tim Cullen - Getting IO and time statistics for SQL Server queries https://www.mssqltips.com/sqlservertip/1255/getting-io-and-time-statistics-for-sql-server-queries/

Real-World Example Nested Views

Real-World Example Cursors

Questions/comments/snide remarks

Thank you! Kris Hokanson Kris@variablesql.com