SlideShare a Scribd company logo
1 of 26
© 2015 IDERA, Inc. All rights reserved.
Proprietary and confidential.
CSI FOR SQL
Learn to be an SQL Sleuth
2© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
AGENDA
 Objectives
 Methodology
 Performance Monitor
 Extended Events
 Bonus Diagnostic Queries
 Questions
3© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
OBJECTIVES
 Meet Service Level Agreements
 Get the most out of existing hardware
 Prevent unnecessary hardware purchases /
upgrades
 Spend $$ where it will make a difference
 Create a Baseline
 Be a Hero (or stay out of the Dog House)
4© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
AGENDA
 Objectives
 Methodology
 Performance Monitor
 Extended Events
 Bonus Diagnostic Queries
 Questions
5© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
Queries
Database
Other Software
Operating System
Hardware
METHODOLOGY
 Bottom Up
 Top Down
 Entire Ecosystem
 Triage Approach
to determine
where to focus
first
• Emergency Room Medical Approach
• Questions & Answers determine
entry point of your investigation
Top
Down
Bottom
Up
6© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
METHODOLOGY – IMMEDIATE ISSUE
 Medical Approach
• Chief Complaint
• History of Present Illness
• Past Medical History
• Past Family Social
• Physical Exam
7© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
METHODOLOGY – IMMEDIATE ISSUE
 Chief Complaint
• Clarification
• “The System is Down!!!!”
− Nobody can work?
− Some people can’t work?
− One person can’t work?
− Some “thing” isn’t working?
• Verification
• Make sure what is being reported is actual factual
information.
• Does the claim agree with what you see happening
on the server?
• Emotional versus Rational
8© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
METHODOLOGY – IMMEDIATE ISSUE
 History of Present Illness
• Who, Context, Timing, Location, Duration?
• AKA: Who, What, When, Where, How Long? 
We’re after the WHY.
 Example
• A complaint comes in that saving a reference
number for an order (what) takes more than 1
minute (how long).
• This began about 3 hours ago (when).
• It appears it is only happening in the order entry
application (where).
• Both users on local workstations and remote
users are reporting problems in this area (who).
9© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
METHODOLOGY – IMMEDIATE ISSUE
 Past Medical History
• Is the problem new?
• When did the problem start?
• Has the server had issues before or recently?
• Any interesting history about the server you’d
like to share?
• “We had a drive failure about 3 weeks ago”
• “We had a consulting company remotely taking care
of this server until recently”
• “We applied SP2 for SQL 2012 last week”
10© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
METHODOLOGY – IMMEDIATE ISSUE
 Past Family Social
• What other applications are on this server?
• Antivirus, Windows Indexing?, Windows Update?
Reporting Services? (on and on)
• How many instances of SQL are on the
server?
• How many databases? What are they?
11© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
METHODOLOGY – IMMEDIATE ISSUE
 Physical Exam
• If Problem is Actively Happening
• Any Blocking?
− Head of Chain?
− What are they running?
• What’s Running Now and what do the
Waits say?
• Extended Event Capture
− Long Running Queries
− Wide Open with Focused Filtering and Short
Duration
• If Problem is Intermittent or Not
Obvious
• Perfmon Capture - PAL
• Diagnostic DMVs
• Extended Event Capture Job
• Long Running Queries
• Set Traps
12© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
AGENDA
 Objectives
 Methodology
 Performance Monitor
 Extended Events
 Bonus Diagnostic Queries
 Questions
13© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
PERFORMANCE MONITOR
 A few quick counters to spot check
• All counters accessible through
start/run/perfmonCounters to Quickly Spot Check When Eyebrows should
raise
Meaning
SQLServer:Buffer Manager:Page Life
Expectancy
< 300 Memory Pressure
SQLServer:Memory Manager: Target
Server Memory
Way less than you think
SQL should be getting
Incorrect Memory Config
Memory: AvailableMB > 30 OS may be starving
Physical Disk: Avg Disk/Sec Read &
Avg Disk Sec/Write
> .100 Disk is insufficient and/or
Memory insufficient.
Physical Disk: % Idle Time Low is bad. 0 means disk is
saturated
Disk is insufficient and/or
Memory insufficient.
Processor: % Processor Time > 80% consistently / usage
is not balanced
Processors insufficient
and/or Memory or Disk
insufficient.
Processor: % Interrupt Time Usually on Proc 0 only.
Should be < 5%
consistently.
Hardware Driver issue (out
of date, incorrect version,
corruption)
14© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
PERFORMANCE MONITOR
 Longer Term Counters to Collect and Review
• Can use sys.dm_os_performance_counters DMV to
query/collect these directly from SQL Server
SQL Server Specific Counters
sql server: sql statistics: batch
requests/sec
sql server: locks: avg wait time(ms)
sql server: sql statistics: sql
compilations/sec
sql server: general statistics: processes
blocked
sql server: sql statistics: sql re-
compilations/sec
sql server: buffer manager: page life
expectancy
sql server: sql statistics: user connections sql server: buffer manager: free pages
sql server: access methods: full scans/sec sql server: buffer manager: lazy writes/sec
sql server: access methods: index
searches/sec
sql server: memory manager: total server
memory (kb)
sql server: access methods: page
splits/sec
sql server: memory manager: target server
memory (kb)
sql server: locks: number of
deadlocks/sec
sql server: memory manager: memory grants
pending
sql server: locks: table lock
15© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
PERFORMANCE MONITOR
 Longer Term Counters to Collect and Review
SQL Server Specific Counters
process(sqlserver): % processor time physical disk: avg disk sec/read
processor: % processor time physical disk: avg disk sec/write
Processor: % interrupt time physical disk: disk reads/sec
memory: available mbytes physical disk: disk writes/sec
memory: page splits/sec physical disk: disk read bytes/sec
physical disk: disk write bytes/sec
16© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
PERFORMANCE MONITOR
 Use Counters Together not in Isolation
Bytes per Second
Disk Response Time
Server A
IOs Per Second
17© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
PERFORMANCE MONITOR
 PAL Tool for SQL
• Create an XML Template of important SQL
Counters
• Generates an HTML Report
• Graphs
• Explanations
• Links
18© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
AGENDA
 Objectives
 Methodology
 Performance Monitor
 Extended Events
 Bonus Diagnostic Queries
 Questions
19© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
EXTENDED EVENTS
 Completed Events Capture
• SQL_Batch_Completed
• RPC_Completed
• SP_Statement_Completed
20© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
EXTENDED EVENT FIELDS
SP_Statement_Completed SQL_Batch_Completed RPC_Completed
statement batch_text statement
source_database_id database_id database_id
transaction_id transaction_id transaction_id
line_number
nt_username nt_username nt_username
client_hostname client_hostname client_hostname
client_app_name client_app_name client_app_name
server_principal_name server_principal_name server_principal_name
session_id session_id session_id
duration duration duration
timestamp timestamp timestamp
logical_reads logical_reads logical_reads
physical_reads physical_reads physical_reads
writes writes writes
cpu_time cpu_time cpu_time
object_id
server_instance_name server_instance_name server_instance_name
name name name
object_name object_name
database_name database_name database_name
row_count row_count row_count
21© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
EXTENDED EVENTS APPROACHES
 Long Running Query
• Duration Filter > X Seconds
 Thousand Paper Cuts
• Wide Open Trace
• Very Short Duration
• Strong Filter
− Spid
− Hostname
− ApplicationName
 Gaps Between SQL Calls
• Wide Open Trace
• Very Short Duration
• Strong Filter
− Spid
− Hostname
− ApplicationName
• Look for silence between Completion of Stmt 1 and Start
of Stmt 2
22© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
AGENDA
 Objectives
 Methodology
 Performance Monitor
 Extended Events
 Bonus Diagnostic Queries
 Questions
23© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
BONUS DIAGNOSTIC QUERIES
 Blocking
• Find head of the blocking chain (spid)
• Sp_who2
− Eyeball it
− Copy/Paste to excel, sort and filter
− Write/Borrow something custom that does recursive SQL
• Google Sp_whoisactive by Adam Machanic
• Select * from master.dbo.sysprocesses
• Look to see what blocking spid is doing
• Dbcc inputbuffer(spid)
• Phonecall / Kill
• Post Mortem
24© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
BONUS DIAGNOSTIC QUERIES
Useful Queries
Desired_Indexes_last10mins.sql
Get_Proc_CPU_Qty_Last10secs.sql
Longest_Running_Queries_Right_Now.sql
Dmv_most_expensive_queries.sql
Dmv_top_100_sps_by_exec_qty.sql
Dmv_top_20_sps_by_cpu_pressure.sql
Dmv_top_20_sps_by_memory_pressure.sql
Dmv_top_20_sps_by_physical_io_pressure.sql
Dmv_top_20_sps_by_logical_writes.sql
25© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
AGENDA
 Objectives
 Methodology
 Performance Monitor
 Extended Events
 Bonus Diagnostic Queries
 Questions
26© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential.
THANKS!
Any questions?
You can find me at:
@sqlgirl
mindycurnutt@hotmail.com

More Related Content

Similar to Geek Sync I CSI for SQL: Learn to be a SQL Sleuth

How to Prevent Captiva Downtime in 3 Steps
How to Prevent Captiva Downtime in 3 StepsHow to Prevent Captiva Downtime in 3 Steps
How to Prevent Captiva Downtime in 3 Steps
Reveille Software
 
What are you waiting for
What are you waiting forWhat are you waiting for
What are you waiting for
Jason Strate
 

Similar to Geek Sync I CSI for SQL: Learn to be a SQL Sleuth (20)

Find and fix SQL Server performance problems faster
Find and fix SQL Server performance problems fasterFind and fix SQL Server performance problems faster
Find and fix SQL Server performance problems faster
 
Some Oracle AWR observations
Some Oracle AWR observationsSome Oracle AWR observations
Some Oracle AWR observations
 
How to Prevent Captiva Downtime in 3 Steps
How to Prevent Captiva Downtime in 3 StepsHow to Prevent Captiva Downtime in 3 Steps
How to Prevent Captiva Downtime in 3 Steps
 
Best Practices for Becoming an Exceptional Postgres DBA
Best Practices for Becoming an Exceptional Postgres DBA Best Practices for Becoming an Exceptional Postgres DBA
Best Practices for Becoming an Exceptional Postgres DBA
 
DockerCon Europe 2018 Monitoring & Logging Workshop
DockerCon Europe 2018 Monitoring & Logging WorkshopDockerCon Europe 2018 Monitoring & Logging Workshop
DockerCon Europe 2018 Monitoring & Logging Workshop
 
OUGLS 2016: How profiling works in MySQL
OUGLS 2016: How profiling works in MySQLOUGLS 2016: How profiling works in MySQL
OUGLS 2016: How profiling works in MySQL
 
Application Performance Troubleshooting 1x1 - Part 2 - Noch mehr Schweine und...
Application Performance Troubleshooting 1x1 - Part 2 - Noch mehr Schweine und...Application Performance Troubleshooting 1x1 - Part 2 - Noch mehr Schweine und...
Application Performance Troubleshooting 1x1 - Part 2 - Noch mehr Schweine und...
 
20150110 my sql-performanceschema
20150110 my sql-performanceschema20150110 my sql-performanceschema
20150110 my sql-performanceschema
 
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
 
Awr + 12c performance tuning
Awr + 12c performance tuningAwr + 12c performance tuning
Awr + 12c performance tuning
 
Hadoop and Manufacturing
Hadoop and ManufacturingHadoop and Manufacturing
Hadoop and Manufacturing
 
What are you waiting for
What are you waiting forWhat are you waiting for
What are you waiting for
 
Oracle Management Cloud
Oracle Management Cloud Oracle Management Cloud
Oracle Management Cloud
 
Oracle Management Cloud
Oracle Management CloudOracle Management Cloud
Oracle Management Cloud
 
Apouc 2014-enterprise-manager-12c
Apouc 2014-enterprise-manager-12cApouc 2014-enterprise-manager-12c
Apouc 2014-enterprise-manager-12c
 
AWR & ASH Analysis
AWR & ASH AnalysisAWR & ASH Analysis
AWR & ASH Analysis
 
Why And When Should We Consider Stream Processing In Our Solutions Teqnation ...
Why And When Should We Consider Stream Processing In Our Solutions Teqnation ...Why And When Should We Consider Stream Processing In Our Solutions Teqnation ...
Why And When Should We Consider Stream Processing In Our Solutions Teqnation ...
 
MySQL Manchester TT - Performance Tuning
MySQL Manchester TT  - Performance TuningMySQL Manchester TT  - Performance Tuning
MySQL Manchester TT - Performance Tuning
 
Simplifying Real-Time Architectures for IoT with Apache Kudu
Simplifying Real-Time Architectures for IoT with Apache KuduSimplifying Real-Time Architectures for IoT with Apache Kudu
Simplifying Real-Time Architectures for IoT with Apache Kudu
 
CA Security Communities Webcast - CA SSO Performance Testing with CA BlazeMeter
CA Security Communities Webcast - CA SSO Performance Testing with CA BlazeMeterCA Security Communities Webcast - CA SSO Performance Testing with CA BlazeMeter
CA Security Communities Webcast - CA SSO Performance Testing with CA BlazeMeter
 

More from IDERA Software

Idera live 2021: The Power of Abstraction by Steve Hoberman
Idera live 2021:  The Power of Abstraction by Steve HobermanIdera live 2021:  The Power of Abstraction by Steve Hoberman
Idera live 2021: The Power of Abstraction by Steve Hoberman
IDERA Software
 
Idera live 2021: Keynote Presentation The Future of Data is The Data Cloud b...
Idera live 2021:  Keynote Presentation The Future of Data is The Data Cloud b...Idera live 2021:  Keynote Presentation The Future of Data is The Data Cloud b...
Idera live 2021: Keynote Presentation The Future of Data is The Data Cloud b...
IDERA Software
 
Idera live 2021: Database Auditing - on-Premises and in the Cloud by Craig M...
Idera live 2021:  Database Auditing - on-Premises and in the Cloud by Craig M...Idera live 2021:  Database Auditing - on-Premises and in the Cloud by Craig M...
Idera live 2021: Database Auditing - on-Premises and in the Cloud by Craig M...
IDERA Software
 

More from IDERA Software (20)

The role of the database administrator (DBA) in 2020: Changes, challenges, an...
The role of the database administrator (DBA) in 2020: Changes, challenges, an...The role of the database administrator (DBA) in 2020: Changes, challenges, an...
The role of the database administrator (DBA) in 2020: Changes, challenges, an...
 
Problems and solutions for migrating databases to the cloud
Problems and solutions for migrating databases to the cloudProblems and solutions for migrating databases to the cloud
Problems and solutions for migrating databases to the cloud
 
Public cloud uses and limitations
Public cloud uses and limitationsPublic cloud uses and limitations
Public cloud uses and limitations
 
Optimize the performance, cost, and value of databases.pptx
Optimize the performance, cost, and value of databases.pptxOptimize the performance, cost, and value of databases.pptx
Optimize the performance, cost, and value of databases.pptx
 
Monitor cloud database with SQL Diagnostic Manager for SQL Server
Monitor cloud database with SQL Diagnostic Manager for SQL ServerMonitor cloud database with SQL Diagnostic Manager for SQL Server
Monitor cloud database with SQL Diagnostic Manager for SQL Server
 
Database administrators (dbas) face increasing pressure to monitor databases
Database administrators (dbas) face increasing pressure to monitor databasesDatabase administrators (dbas) face increasing pressure to monitor databases
Database administrators (dbas) face increasing pressure to monitor databases
 
Six tips for cutting sql server licensing costs
Six tips for cutting sql server licensing costsSix tips for cutting sql server licensing costs
Six tips for cutting sql server licensing costs
 
Idera live 2021: The Power of Abstraction by Steve Hoberman
Idera live 2021:  The Power of Abstraction by Steve HobermanIdera live 2021:  The Power of Abstraction by Steve Hoberman
Idera live 2021: The Power of Abstraction by Steve Hoberman
 
Idera live 2021: Why Data Lakes are Critical for AI, ML, and IoT By Brian Flug
Idera live 2021:  Why Data Lakes are Critical for AI, ML, and IoT  By Brian FlugIdera live 2021:  Why Data Lakes are Critical for AI, ML, and IoT  By Brian Flug
Idera live 2021: Why Data Lakes are Critical for AI, ML, and IoT By Brian Flug
 
Idera live 2021: Will Data Vault add Value to Your Data Warehouse? 3 Signs th...
Idera live 2021: Will Data Vault add Value to Your Data Warehouse? 3 Signs th...Idera live 2021: Will Data Vault add Value to Your Data Warehouse? 3 Signs th...
Idera live 2021: Will Data Vault add Value to Your Data Warehouse? 3 Signs th...
 
Idera live 2021: Managing Digital Transformation on a Budget by Bert Scalzo
Idera live 2021:  Managing Digital Transformation on a Budget by Bert ScalzoIdera live 2021:  Managing Digital Transformation on a Budget by Bert Scalzo
Idera live 2021: Managing Digital Transformation on a Budget by Bert Scalzo
 
Idera live 2021: Keynote Presentation The Future of Data is The Data Cloud b...
Idera live 2021:  Keynote Presentation The Future of Data is The Data Cloud b...Idera live 2021:  Keynote Presentation The Future of Data is The Data Cloud b...
Idera live 2021: Keynote Presentation The Future of Data is The Data Cloud b...
 
Idera live 2021: Managing Databases in the Cloud - the First Step, a Succes...
Idera live 2021:   Managing Databases in the Cloud - the First Step, a Succes...Idera live 2021:   Managing Databases in the Cloud - the First Step, a Succes...
Idera live 2021: Managing Databases in the Cloud - the First Step, a Succes...
 
Idera live 2021: Database Auditing - on-Premises and in the Cloud by Craig M...
Idera live 2021:  Database Auditing - on-Premises and in the Cloud by Craig M...Idera live 2021:  Database Auditing - on-Premises and in the Cloud by Craig M...
Idera live 2021: Database Auditing - on-Premises and in the Cloud by Craig M...
 
Idera live 2021: Performance Tuning Azure SQL Database by Monica Rathbun
Idera live 2021:  Performance Tuning Azure SQL Database by Monica RathbunIdera live 2021:  Performance Tuning Azure SQL Database by Monica Rathbun
Idera live 2021: Performance Tuning Azure SQL Database by Monica Rathbun
 
Geek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERA
Geek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERAGeek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERA
Geek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERA
 
How Users of a Performance Monitoring Tool Can Benefit from an Inventory Mana...
How Users of a Performance Monitoring Tool Can Benefit from an Inventory Mana...How Users of a Performance Monitoring Tool Can Benefit from an Inventory Mana...
How Users of a Performance Monitoring Tool Can Benefit from an Inventory Mana...
 
Benefits of Third Party Tools for MySQL | IDERA
Benefits of Third Party Tools for MySQL | IDERABenefits of Third Party Tools for MySQL | IDERA
Benefits of Third Party Tools for MySQL | IDERA
 
Achieve More with Less Resources | IDERA
Achieve More with Less Resources | IDERAAchieve More with Less Resources | IDERA
Achieve More with Less Resources | IDERA
 
Benefits of SQL Server 2017 and 2019 | IDERA
Benefits of SQL Server 2017 and 2019 | IDERABenefits of SQL Server 2017 and 2019 | IDERA
Benefits of SQL Server 2017 and 2019 | IDERA
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Geek Sync I CSI for SQL: Learn to be a SQL Sleuth

  • 1. © 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. CSI FOR SQL Learn to be an SQL Sleuth
  • 2. 2© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. AGENDA  Objectives  Methodology  Performance Monitor  Extended Events  Bonus Diagnostic Queries  Questions
  • 3. 3© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. OBJECTIVES  Meet Service Level Agreements  Get the most out of existing hardware  Prevent unnecessary hardware purchases / upgrades  Spend $$ where it will make a difference  Create a Baseline  Be a Hero (or stay out of the Dog House)
  • 4. 4© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. AGENDA  Objectives  Methodology  Performance Monitor  Extended Events  Bonus Diagnostic Queries  Questions
  • 5. 5© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. Queries Database Other Software Operating System Hardware METHODOLOGY  Bottom Up  Top Down  Entire Ecosystem  Triage Approach to determine where to focus first • Emergency Room Medical Approach • Questions & Answers determine entry point of your investigation Top Down Bottom Up
  • 6. 6© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. METHODOLOGY – IMMEDIATE ISSUE  Medical Approach • Chief Complaint • History of Present Illness • Past Medical History • Past Family Social • Physical Exam
  • 7. 7© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. METHODOLOGY – IMMEDIATE ISSUE  Chief Complaint • Clarification • “The System is Down!!!!” − Nobody can work? − Some people can’t work? − One person can’t work? − Some “thing” isn’t working? • Verification • Make sure what is being reported is actual factual information. • Does the claim agree with what you see happening on the server? • Emotional versus Rational
  • 8. 8© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. METHODOLOGY – IMMEDIATE ISSUE  History of Present Illness • Who, Context, Timing, Location, Duration? • AKA: Who, What, When, Where, How Long?  We’re after the WHY.  Example • A complaint comes in that saving a reference number for an order (what) takes more than 1 minute (how long). • This began about 3 hours ago (when). • It appears it is only happening in the order entry application (where). • Both users on local workstations and remote users are reporting problems in this area (who).
  • 9. 9© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. METHODOLOGY – IMMEDIATE ISSUE  Past Medical History • Is the problem new? • When did the problem start? • Has the server had issues before or recently? • Any interesting history about the server you’d like to share? • “We had a drive failure about 3 weeks ago” • “We had a consulting company remotely taking care of this server until recently” • “We applied SP2 for SQL 2012 last week”
  • 10. 10© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. METHODOLOGY – IMMEDIATE ISSUE  Past Family Social • What other applications are on this server? • Antivirus, Windows Indexing?, Windows Update? Reporting Services? (on and on) • How many instances of SQL are on the server? • How many databases? What are they?
  • 11. 11© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. METHODOLOGY – IMMEDIATE ISSUE  Physical Exam • If Problem is Actively Happening • Any Blocking? − Head of Chain? − What are they running? • What’s Running Now and what do the Waits say? • Extended Event Capture − Long Running Queries − Wide Open with Focused Filtering and Short Duration • If Problem is Intermittent or Not Obvious • Perfmon Capture - PAL • Diagnostic DMVs • Extended Event Capture Job • Long Running Queries • Set Traps
  • 12. 12© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. AGENDA  Objectives  Methodology  Performance Monitor  Extended Events  Bonus Diagnostic Queries  Questions
  • 13. 13© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. PERFORMANCE MONITOR  A few quick counters to spot check • All counters accessible through start/run/perfmonCounters to Quickly Spot Check When Eyebrows should raise Meaning SQLServer:Buffer Manager:Page Life Expectancy < 300 Memory Pressure SQLServer:Memory Manager: Target Server Memory Way less than you think SQL should be getting Incorrect Memory Config Memory: AvailableMB > 30 OS may be starving Physical Disk: Avg Disk/Sec Read & Avg Disk Sec/Write > .100 Disk is insufficient and/or Memory insufficient. Physical Disk: % Idle Time Low is bad. 0 means disk is saturated Disk is insufficient and/or Memory insufficient. Processor: % Processor Time > 80% consistently / usage is not balanced Processors insufficient and/or Memory or Disk insufficient. Processor: % Interrupt Time Usually on Proc 0 only. Should be < 5% consistently. Hardware Driver issue (out of date, incorrect version, corruption)
  • 14. 14© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. PERFORMANCE MONITOR  Longer Term Counters to Collect and Review • Can use sys.dm_os_performance_counters DMV to query/collect these directly from SQL Server SQL Server Specific Counters sql server: sql statistics: batch requests/sec sql server: locks: avg wait time(ms) sql server: sql statistics: sql compilations/sec sql server: general statistics: processes blocked sql server: sql statistics: sql re- compilations/sec sql server: buffer manager: page life expectancy sql server: sql statistics: user connections sql server: buffer manager: free pages sql server: access methods: full scans/sec sql server: buffer manager: lazy writes/sec sql server: access methods: index searches/sec sql server: memory manager: total server memory (kb) sql server: access methods: page splits/sec sql server: memory manager: target server memory (kb) sql server: locks: number of deadlocks/sec sql server: memory manager: memory grants pending sql server: locks: table lock
  • 15. 15© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. PERFORMANCE MONITOR  Longer Term Counters to Collect and Review SQL Server Specific Counters process(sqlserver): % processor time physical disk: avg disk sec/read processor: % processor time physical disk: avg disk sec/write Processor: % interrupt time physical disk: disk reads/sec memory: available mbytes physical disk: disk writes/sec memory: page splits/sec physical disk: disk read bytes/sec physical disk: disk write bytes/sec
  • 16. 16© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. PERFORMANCE MONITOR  Use Counters Together not in Isolation Bytes per Second Disk Response Time Server A IOs Per Second
  • 17. 17© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. PERFORMANCE MONITOR  PAL Tool for SQL • Create an XML Template of important SQL Counters • Generates an HTML Report • Graphs • Explanations • Links
  • 18. 18© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. AGENDA  Objectives  Methodology  Performance Monitor  Extended Events  Bonus Diagnostic Queries  Questions
  • 19. 19© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. EXTENDED EVENTS  Completed Events Capture • SQL_Batch_Completed • RPC_Completed • SP_Statement_Completed
  • 20. 20© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. EXTENDED EVENT FIELDS SP_Statement_Completed SQL_Batch_Completed RPC_Completed statement batch_text statement source_database_id database_id database_id transaction_id transaction_id transaction_id line_number nt_username nt_username nt_username client_hostname client_hostname client_hostname client_app_name client_app_name client_app_name server_principal_name server_principal_name server_principal_name session_id session_id session_id duration duration duration timestamp timestamp timestamp logical_reads logical_reads logical_reads physical_reads physical_reads physical_reads writes writes writes cpu_time cpu_time cpu_time object_id server_instance_name server_instance_name server_instance_name name name name object_name object_name database_name database_name database_name row_count row_count row_count
  • 21. 21© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. EXTENDED EVENTS APPROACHES  Long Running Query • Duration Filter > X Seconds  Thousand Paper Cuts • Wide Open Trace • Very Short Duration • Strong Filter − Spid − Hostname − ApplicationName  Gaps Between SQL Calls • Wide Open Trace • Very Short Duration • Strong Filter − Spid − Hostname − ApplicationName • Look for silence between Completion of Stmt 1 and Start of Stmt 2
  • 22. 22© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. AGENDA  Objectives  Methodology  Performance Monitor  Extended Events  Bonus Diagnostic Queries  Questions
  • 23. 23© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. BONUS DIAGNOSTIC QUERIES  Blocking • Find head of the blocking chain (spid) • Sp_who2 − Eyeball it − Copy/Paste to excel, sort and filter − Write/Borrow something custom that does recursive SQL • Google Sp_whoisactive by Adam Machanic • Select * from master.dbo.sysprocesses • Look to see what blocking spid is doing • Dbcc inputbuffer(spid) • Phonecall / Kill • Post Mortem
  • 24. 24© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. BONUS DIAGNOSTIC QUERIES Useful Queries Desired_Indexes_last10mins.sql Get_Proc_CPU_Qty_Last10secs.sql Longest_Running_Queries_Right_Now.sql Dmv_most_expensive_queries.sql Dmv_top_100_sps_by_exec_qty.sql Dmv_top_20_sps_by_cpu_pressure.sql Dmv_top_20_sps_by_memory_pressure.sql Dmv_top_20_sps_by_physical_io_pressure.sql Dmv_top_20_sps_by_logical_writes.sql
  • 25. 25© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. AGENDA  Objectives  Methodology  Performance Monitor  Extended Events  Bonus Diagnostic Queries  Questions
  • 26. 26© 2015 IDERA, Inc. All rights reserved. Proprietary and confidential. THANKS! Any questions? You can find me at: @sqlgirl mindycurnutt@hotmail.com