SlideShare a Scribd company logo
Microsoft SQL Server
Monitoring and Profiling
Alireza Sadeghipour, Abouzar Noori
24th Azar 1394
Microsoft SQL Server:
Monitoring and Profiling
• Performance Monitoring
• Estimated Execution Plan
• Indexing
• Database Engine Tuning Advisor
• SQL Server Profiling
Before MS SQL
• Be aware of Select N+1 Problem when using EF lazy loading
• Log EF queries to find the problem:
Performance Monitoring
Resource Monitor
• First of all, check Resource Monitor and find sqlserver.exe
SQL Server Performance Counters
SQL Server Performance Counters
• Access Methods: Full Scans/sec
• Buffer Manager: Buffer Cache Hit Ratio
• Database: Transactions/sec
• Database: Write Transactions/sec
• General Statistics: User Connections
SQL Server Performance Counters (cont.)
• Locks: Lock Requests / Sec
• Locks: Lock Waits / Sec
• Locks: Lock Timeouts/sec
• Locks: Number of Deadlocks/sec
• SQL Statistics: Batch Requests/Sec
• SQL Statistics: SQL Re-Compilations/sec
• SQL Statistics: SQL Compilations/sec
Checking Execution Plan with SSMS
Actual Execution Plan in SQL Server
IO Statistics
• Copy message into http://www.statisticsparser.com/
• Logical reads is the most prominent counter
Indexing
Indexing
• Clustered index
• Primary Key: Includes all columns
• Non-clustered index
• One or more columns: Include as many columns as needed
• SELECT * FROM Device WHERE Serial = ‘0123456789’
• Execution plan suggests to add:
• CREATE NONCLUSTERED INDEX (…) ON Device (Serial)
Indexing (cont.)
• A new index is a new copy of the table, containing “key columns”
and “include columns”
• 4,516 logical read
• SSMS hints:
• Logical reads decreases to 13
Indexing (cont.)
• Indexing helps
• SELECT item using COLUMN = VALUE
• COLUMN compare VALUE
• INDEX name on table (a, b)
• Sort on a values, then b values in each bucket on a
• Not good for
• SELECT id FROM table WHERE a > 100 and b = 200
• SELECT id FROM table WHERE b = 200
• Good for
• SELECT id FROM table WHERE b > 100 and a = 200
• SELECT id FROM table WHERE a > 100
Investigating index usage (index_usage_stats)
• SELECT OBJECT_NAME(ddius.[object_id], ddius.database_id) AS [object_name] ,
ddius.index_id ,
ddius.user_seeks ,
ddius.user_scans ,
ddius.user_lookups ,
ddius.user_seeks + ddius.user_scans + ddius.user_lookups
AS user_reads ,
ddius.user_updates AS user_writes ,
ddius.last_user_scan ,
ddius.last_user_update
FROM sys.dm_db_index_usage_stats ddius
WHERE ddius.database_id > 4 -- filter out system tables
AND OBJECTPROPERTY(ddius.OBJECT_ID, 'IsUserTable') = 1
AND ddius.index_id > 0 -- filter out heaps
ORDER BY ddius.user_scans DESC
Identify indexes that have never been
accessed
• SELECT OBJECT_NAME(i.[object_id]) AS [Table Name] , i.name FROM
sys.indexes AS I INNER JOIN sys.objects AS o ON i.[object_id] =
o.[object_id] WHERE i.index_id NOT IN ( SELECT ddius.index_id
FROM sys.dm_db_index_usage_stats AS ddius
WHERE ddius.[object_id] = i.[object_id] AND i.index_id =
ddius.index_id AND database_id = DB_ID() ) AND o.[type] = 'U‘
ORDER BY OBJECT_NAME(i.[object_id]) ASC
Tune Your Indexing Strategy with SQL Server
DMVs
• https://www.simple-talk.com/sql/performance/tune-your-indexing-
strategy-with-sql-server-dmvs/
Database Engine Tuning Advisor
SQL Server Profiling
Some Columns in DB are Locked!
• Use sp_who2 and check BlkBy to see who has blocked whom
• sp_whoisactive does it in a better way
SQL Server Profiler
Profile Using Execution Plan Cache
• Install sp_BlitzCache
• Run: sp_blitzcache @sort_order = 'reads', @top = 20
• You will find “Query Text”, “Total Reads”, “# Executions”, “Execution Plan”,
and some hints about how to improve performance of those queries.
• It gave us a hint to add the following index:
• We thought indexing this table is not important since it is solely used in
admin panel. But sp_BlitzCache tells that 20% of reads are related to this
function.
Other Diagnosing Stored Procedures
• sp_BlitzIndex: Gives you hints on how much your indexes are used and
suggestions for new indexes and their estimated effect
• sp_Blitz: Checks common health measures of your DB
• sp_AskBrent: For 5 seconds watches your DB and gives you a report on:
• Blocking or long-running queries
• If a backup, DBCC, or index maintenance job was running
• Query wait statistics to figure out SQL Server’s current bottleneck
• Perf. counters for CPU use, slow drive response times, or low Page Life Expectance
• You can create an agent job which runs sp_AskBrent every 15 minutes and
appends the result to a table in your DB (more info)
• All these stored procedures are packaged in the ZIP file containing
sp_BlitzCache
Evidences of Effect!
• # of lock requests / sec
• Avg. wait time
• CPU usage
Questions?

More Related Content

What's hot

Database in Android
Database in AndroidDatabase in Android
Database in Android
MaryadelMar85
 
resource governor
resource governorresource governor
resource governor
Aaron Shilo
 
Query Optimization in SQL Server
Query Optimization in SQL ServerQuery Optimization in SQL Server
Query Optimization in SQL Server
Rajesh Gunasundaram
 
Troubleshooting sql server
Troubleshooting sql serverTroubleshooting sql server
Troubleshooting sql server
Antonios Chatzipavlis
 
SQLite database in android
SQLite database in androidSQLite database in android
SQLite database in android
Gourav Kumar Saini
 
Less11 Security
Less11 SecurityLess11 Security
Less11 Security
vivaankumar
 
Android Database Tutorial
Android Database TutorialAndroid Database Tutorial
Android Database Tutorial
Perfect APK
 
Databases in Android Application
Databases in Android ApplicationDatabases in Android Application
Databases in Android Application
Mark Lester Navarro
 
Persitance Data with sqlite
Persitance Data with sqlitePersitance Data with sqlite
Persitance Data with sqlite
Arif Huda
 
New fordevelopersinsql server2008
New fordevelopersinsql server2008New fordevelopersinsql server2008
New fordevelopersinsql server2008
Aaron Shilo
 
09.1. Android - Local Database (Sqlite)
09.1. Android - Local Database (Sqlite)09.1. Android - Local Database (Sqlite)
09.1. Android - Local Database (Sqlite)
Oum Saokosal
 
Introduction4 SQLite
Introduction4 SQLiteIntroduction4 SQLite
Introduction4 SQLite
Stanley Huang
 
Using sqlite database in android with sqlite manager browser add ons
Using sqlite database in android with sqlite manager browser add onsUsing sqlite database in android with sqlite manager browser add ons
Using sqlite database in android with sqlite manager browser add ons
Vincent Clyde
 
Sqlite
SqliteSqlite
Sqlite
Raghu nath
 
SQLite 3
SQLite 3SQLite 3
SQLite 3
Scott MacVicar
 
Database Performance Tuning
Database Performance Tuning Database Performance Tuning
Database Performance Tuning
Arno Huetter
 
Less03 D B D B C A
Less03  D B  D B C ALess03  D B  D B C A
Less03 D B D B C A
vivaankumar
 
SharePoint Framework, React, and Office UI Fabric spc adriatics 2016
SharePoint Framework, React, and Office UI Fabric spc adriatics 2016SharePoint Framework, React, and Office UI Fabric spc adriatics 2016
SharePoint Framework, React, and Office UI Fabric spc adriatics 2016
Sonja Madsen
 
Less16 Recovery
Less16 RecoveryLess16 Recovery
Less16 Recovery
vivaankumar
 
Less12 Proactive
Less12 ProactiveLess12 Proactive
Less12 Proactive
vivaankumar
 

What's hot (20)

Database in Android
Database in AndroidDatabase in Android
Database in Android
 
resource governor
resource governorresource governor
resource governor
 
Query Optimization in SQL Server
Query Optimization in SQL ServerQuery Optimization in SQL Server
Query Optimization in SQL Server
 
Troubleshooting sql server
Troubleshooting sql serverTroubleshooting sql server
Troubleshooting sql server
 
SQLite database in android
SQLite database in androidSQLite database in android
SQLite database in android
 
Less11 Security
Less11 SecurityLess11 Security
Less11 Security
 
Android Database Tutorial
Android Database TutorialAndroid Database Tutorial
Android Database Tutorial
 
Databases in Android Application
Databases in Android ApplicationDatabases in Android Application
Databases in Android Application
 
Persitance Data with sqlite
Persitance Data with sqlitePersitance Data with sqlite
Persitance Data with sqlite
 
New fordevelopersinsql server2008
New fordevelopersinsql server2008New fordevelopersinsql server2008
New fordevelopersinsql server2008
 
09.1. Android - Local Database (Sqlite)
09.1. Android - Local Database (Sqlite)09.1. Android - Local Database (Sqlite)
09.1. Android - Local Database (Sqlite)
 
Introduction4 SQLite
Introduction4 SQLiteIntroduction4 SQLite
Introduction4 SQLite
 
Using sqlite database in android with sqlite manager browser add ons
Using sqlite database in android with sqlite manager browser add onsUsing sqlite database in android with sqlite manager browser add ons
Using sqlite database in android with sqlite manager browser add ons
 
Sqlite
SqliteSqlite
Sqlite
 
SQLite 3
SQLite 3SQLite 3
SQLite 3
 
Database Performance Tuning
Database Performance Tuning Database Performance Tuning
Database Performance Tuning
 
Less03 D B D B C A
Less03  D B  D B C ALess03  D B  D B C A
Less03 D B D B C A
 
SharePoint Framework, React, and Office UI Fabric spc adriatics 2016
SharePoint Framework, React, and Office UI Fabric spc adriatics 2016SharePoint Framework, React, and Office UI Fabric spc adriatics 2016
SharePoint Framework, React, and Office UI Fabric spc adriatics 2016
 
Less16 Recovery
Less16 RecoveryLess16 Recovery
Less16 Recovery
 
Less12 Proactive
Less12 ProactiveLess12 Proactive
Less12 Proactive
 

Viewers also liked

FGFisher_resume
FGFisher_resumeFGFisher_resume
FGFisher_resume
Frank Fisher PMP
 
Pervaporacion
Pervaporacion Pervaporacion
Pervaporacion
Elias Rodas Palomino
 
Amin priatna(A3.1300033)
Amin priatna(A3.1300033)Amin priatna(A3.1300033)
Amin priatna(A3.1300033)aminpriatnaa
 
Group 7
Group 7Group 7
Vision, leadership and ethics
Vision, leadership and ethicsVision, leadership and ethics
Vision, leadership and ethics
The Concept Store
 
KACHEPA CURRICULUM VITAE 2015 REVISED
KACHEPA CURRICULUM VITAE 2015 REVISEDKACHEPA CURRICULUM VITAE 2015 REVISED
KACHEPA CURRICULUM VITAE 2015 REVISED
KENALA KACHEPA
 
Patrick O'Brien - Guerras y crecimiento económico a largo plazo
Patrick O'Brien - Guerras y crecimiento económico a largo plazoPatrick O'Brien - Guerras y crecimiento económico a largo plazo
Patrick O'Brien - Guerras y crecimiento económico a largo plazo
Fundación Ramón Areces
 
Guido Smorto, Sharing In the Cities: Local Rules for a Global Innovation
Guido Smorto, Sharing In the Cities: Local Rules for a Global InnovationGuido Smorto, Sharing In the Cities: Local Rules for a Global Innovation
Guido Smorto, Sharing In the Cities: Local Rules for a Global Innovation
LabGov
 
Microservices; A Quick Introduction
Microservices; A Quick IntroductionMicroservices; A Quick Introduction
Microservices; A Quick Introduction
Abouzar Noori
 
Logo competition BG
Logo competition BGLogo competition BG
Logo competition BG
М. М.
 
Nestle Performance Management (2)
Nestle Performance Management (2)Nestle Performance Management (2)
Nestle Performance Management (2)
Muhammad Kamran Aqeel
 

Viewers also liked (11)

FGFisher_resume
FGFisher_resumeFGFisher_resume
FGFisher_resume
 
Pervaporacion
Pervaporacion Pervaporacion
Pervaporacion
 
Amin priatna(A3.1300033)
Amin priatna(A3.1300033)Amin priatna(A3.1300033)
Amin priatna(A3.1300033)
 
Group 7
Group 7Group 7
Group 7
 
Vision, leadership and ethics
Vision, leadership and ethicsVision, leadership and ethics
Vision, leadership and ethics
 
KACHEPA CURRICULUM VITAE 2015 REVISED
KACHEPA CURRICULUM VITAE 2015 REVISEDKACHEPA CURRICULUM VITAE 2015 REVISED
KACHEPA CURRICULUM VITAE 2015 REVISED
 
Patrick O'Brien - Guerras y crecimiento económico a largo plazo
Patrick O'Brien - Guerras y crecimiento económico a largo plazoPatrick O'Brien - Guerras y crecimiento económico a largo plazo
Patrick O'Brien - Guerras y crecimiento económico a largo plazo
 
Guido Smorto, Sharing In the Cities: Local Rules for a Global Innovation
Guido Smorto, Sharing In the Cities: Local Rules for a Global InnovationGuido Smorto, Sharing In the Cities: Local Rules for a Global Innovation
Guido Smorto, Sharing In the Cities: Local Rules for a Global Innovation
 
Microservices; A Quick Introduction
Microservices; A Quick IntroductionMicroservices; A Quick Introduction
Microservices; A Quick Introduction
 
Logo competition BG
Logo competition BGLogo competition BG
Logo competition BG
 
Nestle Performance Management (2)
Nestle Performance Management (2)Nestle Performance Management (2)
Nestle Performance Management (2)
 

Similar to SQL Server 2014 Monitoring and Profiling

Oracle performance tuning_sfsf
Oracle performance tuning_sfsfOracle performance tuning_sfsf
Oracle performance tuning_sfsf
Mao Geng
 
SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1
sqlserver.co.il
 
Database Fundamental Concepts- Series 1 - Performance Analysis
Database Fundamental Concepts- Series 1 - Performance AnalysisDatabase Fundamental Concepts- Series 1 - Performance Analysis
Database Fundamental Concepts- Series 1 - Performance Analysis
DAGEOP LTD
 
Sql server basics
Sql server basicsSql server basics
Sql server basics
VishalJharwade
 
pdf-download-db-time-based-oracle-performance-tuning-theory-and.pdf
pdf-download-db-time-based-oracle-performance-tuning-theory-and.pdfpdf-download-db-time-based-oracle-performance-tuning-theory-and.pdf
pdf-download-db-time-based-oracle-performance-tuning-theory-and.pdf
cookie1969
 
Remote DBA Experts SQL Server 2008 New Features
Remote DBA Experts SQL Server 2008 New FeaturesRemote DBA Experts SQL Server 2008 New Features
Remote DBA Experts SQL Server 2008 New Features
Remote DBA Experts
 
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAsOracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Zohar Elkayam
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx
KareemBullard1
 
Database training for developers
Database training for developersDatabase training for developers
Database training for developers
Bhaveshkumar Thakkar
 
A Complete BI Solution in About an Hour!
A Complete BI Solution in About an Hour!A Complete BI Solution in About an Hour!
A Complete BI Solution in About an Hour!
Aaron King
 
Oracle Database : Addressing a performance issue the drilldown approach
Oracle Database : Addressing a performance issue the drilldown approachOracle Database : Addressing a performance issue the drilldown approach
Oracle Database : Addressing a performance issue the drilldown approach
Laurent Leturgez
 
Tarabica 2019 (Belgrade, Serbia) - SQL Server performance troubleshooting
Tarabica 2019 (Belgrade, Serbia) - SQL Server performance troubleshootingTarabica 2019 (Belgrade, Serbia) - SQL Server performance troubleshooting
Tarabica 2019 (Belgrade, Serbia) - SQL Server performance troubleshooting
Jovan Popovic
 
The dr overnight dba
The dr overnight dbaThe dr overnight dba
The dr overnight dba
gdabate
 
Database Testing
Database TestingDatabase Testing
Database Testing
Siva Kotilingam Pallikonda
 
Database continuous integration, unit test and functional test
Database continuous integration, unit test and functional testDatabase continuous integration, unit test and functional test
Database continuous integration, unit test and functional test
Harry Zheng
 
Average Active Sessions RMOUG2007
Average Active Sessions RMOUG2007Average Active Sessions RMOUG2007
Average Active Sessions RMOUG2007
John Beresniewicz
 
Taming the shrew Power BI
Taming the shrew Power BITaming the shrew Power BI
Taming the shrew Power BI
Kellyn Pot'Vin-Gorman
 
Optimising Queries - Series 1 Query Optimiser Architecture
Optimising Queries - Series 1 Query Optimiser ArchitectureOptimising Queries - Series 1 Query Optimiser Architecture
Optimising Queries - Series 1 Query Optimiser Architecture
DAGEOP LTD
 
Optimizing Data Accessin Sq Lserver2005
Optimizing Data Accessin Sq Lserver2005Optimizing Data Accessin Sq Lserver2005
Optimizing Data Accessin Sq Lserver2005
rainynovember12
 
Sage 300 ERP: Technical Tour of Diagnostic Tools
Sage 300 ERP: Technical Tour of Diagnostic ToolsSage 300 ERP: Technical Tour of Diagnostic Tools
Sage 300 ERP: Technical Tour of Diagnostic Tools
Sage 300 ERP CS
 

Similar to SQL Server 2014 Monitoring and Profiling (20)

Oracle performance tuning_sfsf
Oracle performance tuning_sfsfOracle performance tuning_sfsf
Oracle performance tuning_sfsf
 
SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1
 
Database Fundamental Concepts- Series 1 - Performance Analysis
Database Fundamental Concepts- Series 1 - Performance AnalysisDatabase Fundamental Concepts- Series 1 - Performance Analysis
Database Fundamental Concepts- Series 1 - Performance Analysis
 
Sql server basics
Sql server basicsSql server basics
Sql server basics
 
pdf-download-db-time-based-oracle-performance-tuning-theory-and.pdf
pdf-download-db-time-based-oracle-performance-tuning-theory-and.pdfpdf-download-db-time-based-oracle-performance-tuning-theory-and.pdf
pdf-download-db-time-based-oracle-performance-tuning-theory-and.pdf
 
Remote DBA Experts SQL Server 2008 New Features
Remote DBA Experts SQL Server 2008 New FeaturesRemote DBA Experts SQL Server 2008 New Features
Remote DBA Experts SQL Server 2008 New Features
 
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAsOracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx
 
Database training for developers
Database training for developersDatabase training for developers
Database training for developers
 
A Complete BI Solution in About an Hour!
A Complete BI Solution in About an Hour!A Complete BI Solution in About an Hour!
A Complete BI Solution in About an Hour!
 
Oracle Database : Addressing a performance issue the drilldown approach
Oracle Database : Addressing a performance issue the drilldown approachOracle Database : Addressing a performance issue the drilldown approach
Oracle Database : Addressing a performance issue the drilldown approach
 
Tarabica 2019 (Belgrade, Serbia) - SQL Server performance troubleshooting
Tarabica 2019 (Belgrade, Serbia) - SQL Server performance troubleshootingTarabica 2019 (Belgrade, Serbia) - SQL Server performance troubleshooting
Tarabica 2019 (Belgrade, Serbia) - SQL Server performance troubleshooting
 
The dr overnight dba
The dr overnight dbaThe dr overnight dba
The dr overnight dba
 
Database Testing
Database TestingDatabase Testing
Database Testing
 
Database continuous integration, unit test and functional test
Database continuous integration, unit test and functional testDatabase continuous integration, unit test and functional test
Database continuous integration, unit test and functional test
 
Average Active Sessions RMOUG2007
Average Active Sessions RMOUG2007Average Active Sessions RMOUG2007
Average Active Sessions RMOUG2007
 
Taming the shrew Power BI
Taming the shrew Power BITaming the shrew Power BI
Taming the shrew Power BI
 
Optimising Queries - Series 1 Query Optimiser Architecture
Optimising Queries - Series 1 Query Optimiser ArchitectureOptimising Queries - Series 1 Query Optimiser Architecture
Optimising Queries - Series 1 Query Optimiser Architecture
 
Optimizing Data Accessin Sq Lserver2005
Optimizing Data Accessin Sq Lserver2005Optimizing Data Accessin Sq Lserver2005
Optimizing Data Accessin Sq Lserver2005
 
Sage 300 ERP: Technical Tour of Diagnostic Tools
Sage 300 ERP: Technical Tour of Diagnostic ToolsSage 300 ERP: Technical Tour of Diagnostic Tools
Sage 300 ERP: Technical Tour of Diagnostic Tools
 

Recently uploaded

J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
Bert Jan Schrijver
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
VALiNTRY360
 
Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
Karya Keeper
 
YAML crash COURSE how to write yaml file for adding configuring details
YAML crash COURSE how to write yaml file for adding configuring detailsYAML crash COURSE how to write yaml file for adding configuring details
YAML crash COURSE how to write yaml file for adding configuring details
NishanthaBulumulla1
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
Rakesh Kumar R
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
Peter Muessig
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
GohKiangHock
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
TaghreedAltamimi
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
Massimo Artizzu
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 

Recently uploaded (20)

J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
 
Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
 
YAML crash COURSE how to write yaml file for adding configuring details
YAML crash COURSE how to write yaml file for adding configuring detailsYAML crash COURSE how to write yaml file for adding configuring details
YAML crash COURSE how to write yaml file for adding configuring details
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 

SQL Server 2014 Monitoring and Profiling

  • 1. Microsoft SQL Server Monitoring and Profiling Alireza Sadeghipour, Abouzar Noori 24th Azar 1394
  • 2. Microsoft SQL Server: Monitoring and Profiling • Performance Monitoring • Estimated Execution Plan • Indexing • Database Engine Tuning Advisor • SQL Server Profiling
  • 3. Before MS SQL • Be aware of Select N+1 Problem when using EF lazy loading • Log EF queries to find the problem:
  • 5. Resource Monitor • First of all, check Resource Monitor and find sqlserver.exe
  • 7. SQL Server Performance Counters • Access Methods: Full Scans/sec • Buffer Manager: Buffer Cache Hit Ratio • Database: Transactions/sec • Database: Write Transactions/sec • General Statistics: User Connections
  • 8. SQL Server Performance Counters (cont.) • Locks: Lock Requests / Sec • Locks: Lock Waits / Sec • Locks: Lock Timeouts/sec • Locks: Number of Deadlocks/sec • SQL Statistics: Batch Requests/Sec • SQL Statistics: SQL Re-Compilations/sec • SQL Statistics: SQL Compilations/sec
  • 10. Actual Execution Plan in SQL Server
  • 11. IO Statistics • Copy message into http://www.statisticsparser.com/ • Logical reads is the most prominent counter
  • 13. Indexing • Clustered index • Primary Key: Includes all columns • Non-clustered index • One or more columns: Include as many columns as needed • SELECT * FROM Device WHERE Serial = ‘0123456789’ • Execution plan suggests to add: • CREATE NONCLUSTERED INDEX (…) ON Device (Serial)
  • 14. Indexing (cont.) • A new index is a new copy of the table, containing “key columns” and “include columns” • 4,516 logical read • SSMS hints: • Logical reads decreases to 13
  • 15. Indexing (cont.) • Indexing helps • SELECT item using COLUMN = VALUE • COLUMN compare VALUE • INDEX name on table (a, b) • Sort on a values, then b values in each bucket on a • Not good for • SELECT id FROM table WHERE a > 100 and b = 200 • SELECT id FROM table WHERE b = 200 • Good for • SELECT id FROM table WHERE b > 100 and a = 200 • SELECT id FROM table WHERE a > 100
  • 16. Investigating index usage (index_usage_stats) • SELECT OBJECT_NAME(ddius.[object_id], ddius.database_id) AS [object_name] , ddius.index_id , ddius.user_seeks , ddius.user_scans , ddius.user_lookups , ddius.user_seeks + ddius.user_scans + ddius.user_lookups AS user_reads , ddius.user_updates AS user_writes , ddius.last_user_scan , ddius.last_user_update FROM sys.dm_db_index_usage_stats ddius WHERE ddius.database_id > 4 -- filter out system tables AND OBJECTPROPERTY(ddius.OBJECT_ID, 'IsUserTable') = 1 AND ddius.index_id > 0 -- filter out heaps ORDER BY ddius.user_scans DESC
  • 17. Identify indexes that have never been accessed • SELECT OBJECT_NAME(i.[object_id]) AS [Table Name] , i.name FROM sys.indexes AS I INNER JOIN sys.objects AS o ON i.[object_id] = o.[object_id] WHERE i.index_id NOT IN ( SELECT ddius.index_id FROM sys.dm_db_index_usage_stats AS ddius WHERE ddius.[object_id] = i.[object_id] AND i.index_id = ddius.index_id AND database_id = DB_ID() ) AND o.[type] = 'U‘ ORDER BY OBJECT_NAME(i.[object_id]) ASC
  • 18. Tune Your Indexing Strategy with SQL Server DMVs • https://www.simple-talk.com/sql/performance/tune-your-indexing- strategy-with-sql-server-dmvs/
  • 20.
  • 21.
  • 23. Some Columns in DB are Locked! • Use sp_who2 and check BlkBy to see who has blocked whom • sp_whoisactive does it in a better way
  • 25. Profile Using Execution Plan Cache • Install sp_BlitzCache • Run: sp_blitzcache @sort_order = 'reads', @top = 20 • You will find “Query Text”, “Total Reads”, “# Executions”, “Execution Plan”, and some hints about how to improve performance of those queries. • It gave us a hint to add the following index: • We thought indexing this table is not important since it is solely used in admin panel. But sp_BlitzCache tells that 20% of reads are related to this function.
  • 26. Other Diagnosing Stored Procedures • sp_BlitzIndex: Gives you hints on how much your indexes are used and suggestions for new indexes and their estimated effect • sp_Blitz: Checks common health measures of your DB • sp_AskBrent: For 5 seconds watches your DB and gives you a report on: • Blocking or long-running queries • If a backup, DBCC, or index maintenance job was running • Query wait statistics to figure out SQL Server’s current bottleneck • Perf. counters for CPU use, slow drive response times, or low Page Life Expectance • You can create an agent job which runs sp_AskBrent every 15 minutes and appends the result to a table in your DB (more info) • All these stored procedures are packaged in the ZIP file containing sp_BlitzCache
  • 27. Evidences of Effect! • # of lock requests / sec • Avg. wait time • CPU usage