SlideShare ist ein Scribd-Unternehmen logo
1 von 40
Downloaden Sie, um offline zu lesen
C H A P T E R
Troubleshooting
SQL Server
Athens Oct 23, 2015
Presenter introduction
 1982 - I have been started with computers.
 1988 - I started my professional carrier in computers industry.
 1996 - I have been started to work with SQL Server version 6.0
 1998 - I earned my first certification at Microsoft as Microsoft Certified
Solution Developer (3rd in Greece) and started my carrier as
Microsoft Certified Trainer (MCT) with more than 25.000 hours
of training until now!
 2010 - I became for first time Microsoft MVP on SQL Server
I created the SQL School Greece (www.sqlschool.gr)
 2012 - I became MCT Regional Lead by Microsoft Learning Program.
 2013 - I was certified as MCSE : Data Platform,
MCSE : Business Intelligence
Antonios
Chatzipavlis
Database Architect
SQL Server Evangelist
MCT, MCSE, MCITP, MCPD, MCSD, MCDBA,
MCSA, MCTS, MCAD, MCP, OCA, ITIL-F
Follow us in social media
Twitter : @antoniosch / @sqlschool
Facebook : fb/sqlschoolgr
YouTube : yt/user/achatzipavlis
LinkedIn : SQL School Greece group
Need help?
help@sqlschool.gr
Presentation outline
01: SQL Server Monitoring Overview
02: SQL Server Threading Model
03: Using Wait Statistics
04: Using Extended Events
05: Create your Baseline
C H A P T E R
01
SQL Server Monitoring Overview
 Why Monitor?
 Guidelines for Monitoring
 Monitoring Tools for SQL Server
Why Monitor?
 Diagnosing causes of performance issues
 Response Time
 Throughput of the system
 Detecting and resolving concurrency issues
 SQL Server uses locks to ensure data consistency.
 Identifying changing trends in resource utilization
 Capacity planning to identify the required hardware resources to support the
database workload.
 It is important to monitor resource utilization changes
Guidelines for Monitoring
 Understand the workloads you need to support
 Every workload has different requirements
 You need to understand its workloads so that you can identify the relevant metrics to monitor
 Prioritize resources based on the importance of each workload to the business
 Establish a baseline
 A common mistake is to wait until there is a problem before monitoring the SQL Server solution
 A better approach is to identify the key metrics that your workloads rely on, and record baseline
values for these metrics when the system is operating normally
 Monitor regularly to track changes in key metrics.
 It is generally better to proactively monitor the system on a regular basis to identify any trends
that signify changes in the way the workloads consume resources.
 With this approach, you can plan server upgrades or application optimizations before they
become critical.
Monitoring Tools for SQL Server
Build in and External Tools
Activity Monitor
A component of SQL Server Management Studio that
enables DBAs to view details of current activity in the
database engine
Dynamic Management
View and Functions
Database objects that provide insight into internal SQL
Server operations
Performance Monitor
A windows administrative tool that you can use to record
values for multiple performance counters over a period of
time, and analyze results in a variety of chart
SQL Server Profiler
A tracing and profiling tool that you can use to record
details of Transact-SQL and other events in a SQL Server
workload. We can replay or use it as a source for tuning
SQL Trace A lightweight, Transact-SQL based programming interface
for tracing SQL Server activity
Monitoring Tools for SQL Server
Build in and External Tools
Database Engine Tuning
Advisor
A tool provided with SQL Server for tuning indexes and
statistics based on a known workload
SQL Server Utility Control
Point
A centralized management portal for monitoring server
health for multiple instances based on specific collection
sets
SQL Server Extended
Events
A lightweight eventing architecture.
SQL Server Data
Collection
An automated system for collecting and storing and
reporting performance data for multiple SQL Server
instances
Distributed Replay An advanced tool for replaying workloads across a
potentially distributed set of servers
Monitoring Tools for SQL Server
Build in and External Tools
Microsoft System Center
Operations Manager
An enterprise-wide infrastructure management solution
that uses management packs to collect performance and
health data from Windows and application services
SqlDiag Tool
The SQLdiag utility is a general purpose diagnostics
collection utility that can be run as a console application or
as a service
sp_WhoIsActive
Provides detailed information about all of the sessions
running on your SQL Server system, including what they’re
doing and how they’re impacting server behavior
sp_Blitz SQL Server health and warning check
Performance Monitor
Windows Performance Monitor is an operating system
tool that brings together several previously disparate
performance and monitoring tool
Monitoring Tools for SQL Server
SQL Server 2016
Query Store
An enterprise-wide infrastructure management solution
that uses management packs to collect performance and
health data from Windows and application services
Live Query Stats
Windows Performance Monitor is an operating system
tool that brings together several previously disparate
performance and monitoring tool
C H A P T E R
02
SQL Server Threading Model
 Introduction
 What a thread is
 Thread Scheduling
 SQL Server Schedulers
 Thread States
 The Waiter List
 The Runnable Queue
Introduction
 SQL Server is an OS on Windows OS
 It performs and controls its own:
 Memory management
 I/O
 Scheduling
What a thread is
 A thread is unit of execution within a process
 Multiple threads can exist within a process
 Each is given small amount of processor time
 Waits while other threads execute (called scheduling)
 SQL Server uses OS threads to perform its work
 Called worker threads
 Dedicated threads exists
 Such as for performing checkpoints, deadlock monitoring, and ghost record cleanup
 Most are in a pool of threads that SQL Server uses to process user requests
(Working Threads)
Thread Scheduling
 SQL Server has its own thread scheduling
 Called non-preemptive scheduling
 Is more efficient than Windows scheduling
 Performed by the SQLOS layer of the Storage Engine
 Each processor core (logical or physical) has a scheduler
 A scheduler is responsible for managing the execution of work by threads
 Schedulers exist for user threads and for internal operations
 Use the sys.dm_os_schedulers DMV to view schedulers
SQL Server Schedulers
Processor
Runnable
Queue
Waiter List
One scheduler per logical or physical processor core
Plus some extra ones for internal tasks and the DAC
Thread States
 RUNNING
 The thread is currently executing on the processor
 SUSPENDED
 The thread is currently on the Waiter List waiting for a resource
 RUNNABLE
 The thread is currently on the Runnable Queue waiting to execute on the
processor
The Waiter List
 Is an unordered list of threads that are suspended
 Any thread can be notified at any time that the resource it is waiting for is now
available
 No time limit for a thread on the waiter list
 Although execution timeouts or lock timeouts may take effect
 No limit on the number of threads on waiter list
 The sys.dm_os_waiting_tasks DMV
 Shows which threads are currently waiting and what they are waiting for
The Runnable Queue
 Is a strict First-In-First-Out (FIFO) queue
 Resource Governor exception
 The sys.dm_os_schedulers DMV shows the size of the
Runnable Queue in Runnable_tasks_count column
Examine Schedulers
02
Examine Schedulers
Examine Waiting Tasks
C H A P T E R
03
Using Wait Statistics
 Waits and Queues
 Wait Times
 DMVs for Waits
Waits and Queues
 Waits
 Wait is when a thread that's running on the processor cannot proceed because
it needs a resource and the resource that it needs is not available
 The thread state changed from RUNNING to SUSPENDED
 Moved to Waiter List and remains on the list until it became available
 Queues
 Is a generic term and means what's stopping the thread being able to get its
resource
 PAGEIOLATCH_XX : The I/O subsystem need to complete the I/O
 LCK_M_XX : Another thread holding an incompatible lock
 CXPACKET : Another thread needs to complete its portion of work
Wait Times
Wait time=Resource Wait time + Signal Wait time
 Wait time
 Is the time spent from when a thread is running on the processor (RUNNING)
moved to the Waiter List (SUSPENDED) and is being signaled and moving back
onto the runnable queue (RUNNABLE) and is going back to running
 Resource Wait time
 Time spent on the Waiter List with state SUSPENDED
 Signal Wait time
 Time spent on the Runnable Queue with state RUNNABLE
DMVs for Waits
 sys.dm_os_waiting_tasks
 Shows all threads that are currently suspended
 Think of it as the ‘what is happening right now?’ view of a server
 The first thing to run when approaching a ‘slow’ server
 sys.dm_os_wait_stats
 Shows aggregated wait statistics for all wait types
 Aggregated since the server started or the wait statistics were cleared
 Some math is required to make the results useful
 Calculating the resource wait time
 Calculating the average times rather than the total times
Using Waits DMVs
03
C H A P T E R
04
Using Extended Events
 Why Extended Events?
 Switch from SQL Trace to Xevents
 Extended Events Architecture
 Event Life Cycle
 Targets
Why Extended Events?
 It’s the FUTURE
 SQL Trace is a deprecated feature in SQL Server 2012
 This makes understanding XE crucial to supporting SQL Server in the future
 Less overhead
 Lightweight to minimize impact
 Provides minimum schema of data that is specific to the event being fired
 Events are filtered early in the firing lifecycle based on the predicates
 Flexibility and Power
 Allows complex configurations for event collection that simplify problem identification.
 Many events in more recent releases
Switch from SQL Trace to XEvents
 Events Mapping Query
 Column to Action Mapping Query
select xe.xe_event_name,st.name
from sys.trace_xe_event_map as xe
inner join sys.trace_events as st
on xe.trace_event_id = st.trace_event_id;
select xe.xe_action_name, tc.name
from sys.trace_xe_action_map as xe
inner join sys.trace_columns as tc
on xe.trace_column_id = tc.trace_column_id;
Extended Events Architecture
 Sessions
 Are a functional boundary for configuration of events
 Events
 Correspond to well-know points of code
 Predicates
 Boolean expressions that define the conditions required for an event to actually fire
 Actions
 Actions only execute after predicate evaluation determines the event will fire
 Targets
 Targets are event consumers
Event Life Cycle
Event point
encountered in code
Is Event Enabled
in a session Code Continues
Buffer Data for
Asynchronus Targets
Send to Synchronous
Targets Immediately
Execute Actions and
Collect data
(if applicable)
Are there
configurable
columns
Collect
non-configurable
column data
Passes Filter
Criteria (Predicate)
Collect Configurable
Column data
No
No
Yes
Yes
Yes
Targets
 Event counter
 Counts all specified events that occur during an Extended Events session.
 Use to obtain information about workload characteristics without adding the
overhead of full event collection.
 This is a synchronous target.
 Event file
 Use to write event session output from complete memory buffers to disk.
 This is an asynchronous target.
Targets
 Event pairing
 Many kinds of events occur in pairs, such as lock acquires and lock releases.
 Use to determine when a specified paired event does not occur in a matched
set.
 This is an asynchronous target.
 Event Tracing for Windows (ETW)
 Use to correlate SQL Server events with Windows operating system or
application event data.
 This is a synchronous target.
Targets
 Histogram
 Use to count the number of times that a specified event occurs, based on a
specified event column or action.
 This is an asynchronous target.
 Ring buffer
 Use to hold the event data in memory on a first-in first-out (FIFO) basis, or on a
per-event FIFO basis.
 This is an asynchronous target.
Use case scenarios of
Extended Events
04
C H A P T E R
05
Create your Baseline
Create Baseline
05
Summary
 SQL Server Monitoring Overview
 SQL Server Threading Model
 Using Wait Statistics
 Using Extended Events
 Create your Baseline
Questions?
Thank you!
SELECT
KNOWLEDGE
FROM
SQL SERVER
http://www.sqlschool.gr
Copyright © 2015 SQL School Greece
CHAPTER

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and AdvisorsYour tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
 
Cassandra Introduction & Features
Cassandra Introduction & FeaturesCassandra Introduction & Features
Cassandra Introduction & Features
 
Always on in sql server 2017
Always on in sql server 2017Always on in sql server 2017
Always on in sql server 2017
 
Apache Spark Architecture
Apache Spark ArchitectureApache Spark Architecture
Apache Spark Architecture
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuning
 
MS-SQL SERVER ARCHITECTURE
MS-SQL SERVER ARCHITECTUREMS-SQL SERVER ARCHITECTURE
MS-SQL SERVER ARCHITECTURE
 
NoSQL Databases: Why, what and when
NoSQL Databases: Why, what and whenNoSQL Databases: Why, what and when
NoSQL Databases: Why, what and when
 
PostgreSQL.pptx
PostgreSQL.pptxPostgreSQL.pptx
PostgreSQL.pptx
 
Understanding oracle rac internals part 1 - slides
Understanding oracle rac internals   part 1 - slidesUnderstanding oracle rac internals   part 1 - slides
Understanding oracle rac internals part 1 - slides
 
The Roadmap for SQL Server 2019
The Roadmap for SQL Server 2019The Roadmap for SQL Server 2019
The Roadmap for SQL Server 2019
 
SQL Server Performance Tuning Baseline
SQL Server Performance Tuning BaselineSQL Server Performance Tuning Baseline
SQL Server Performance Tuning Baseline
 
Enable GoldenGate Monitoring with OEM 12c/JAgent
Enable GoldenGate Monitoring with OEM 12c/JAgentEnable GoldenGate Monitoring with OEM 12c/JAgent
Enable GoldenGate Monitoring with OEM 12c/JAgent
 
TFA Collector - what can one do with it
TFA Collector - what can one do with it TFA Collector - what can one do with it
TFA Collector - what can one do with it
 
How to design a file system
How to design a file systemHow to design a file system
How to design a file system
 
NA14G05 - A DB2 DBAs Guide to pureScale.pdf
NA14G05 - A DB2 DBAs Guide to pureScale.pdfNA14G05 - A DB2 DBAs Guide to pureScale.pdf
NA14G05 - A DB2 DBAs Guide to pureScale.pdf
 
Lecture2 oracle ppt
Lecture2 oracle pptLecture2 oracle ppt
Lecture2 oracle ppt
 
Oracle AWR Data mining
Oracle AWR Data miningOracle AWR Data mining
Oracle AWR Data mining
 
Map reduce vs spark
Map reduce vs sparkMap reduce vs spark
Map reduce vs spark
 
PL22 - Backup and Restore Performance.pptx
PL22 - Backup and Restore Performance.pptxPL22 - Backup and Restore Performance.pptx
PL22 - Backup and Restore Performance.pptx
 
Problems with PostgreSQL on Multi-core Systems with MultiTerabyte Data
Problems with PostgreSQL on Multi-core Systems with MultiTerabyte DataProblems with PostgreSQL on Multi-core Systems with MultiTerabyte Data
Problems with PostgreSQL on Multi-core Systems with MultiTerabyte Data
 

Andere mochten auch

Pre and post tips to installing sql server correctly
Pre and post tips to installing sql server correctlyPre and post tips to installing sql server correctly
Pre and post tips to installing sql server correctly
Antonios Chatzipavlis
 

Andere mochten auch (20)

Implementing Mobile Reports in SQL Sserver 2016 Reporting Services
Implementing Mobile Reports in SQL Sserver 2016 Reporting ServicesImplementing Mobile Reports in SQL Sserver 2016 Reporting Services
Implementing Mobile Reports in SQL Sserver 2016 Reporting Services
 
Introduction to Machine Learning on Azure
Introduction to Machine Learning on AzureIntroduction to Machine Learning on Azure
Introduction to Machine Learning on Azure
 
Performance Monitoring And Tuning In Sql Server 2008 Tsql
Performance Monitoring And Tuning In Sql Server 2008 TsqlPerformance Monitoring And Tuning In Sql Server 2008 Tsql
Performance Monitoring And Tuning In Sql Server 2008 Tsql
 
Паралельний імпорт: економіко-правові аспекти регулювання
Паралельний імпорт: економіко-правові аспекти регулюванняПаралельний імпорт: економіко-правові аспекти регулювання
Паралельний імпорт: економіко-правові аспекти регулювання
 
Department Row Level Security Customization For People Soft General Ledger.Ppt
Department Row Level Security Customization For People Soft General Ledger.PptDepartment Row Level Security Customization For People Soft General Ledger.Ppt
Department Row Level Security Customization For People Soft General Ledger.Ppt
 
Stretch db sql server 2016 (sn0028)
Stretch db   sql server 2016 (sn0028)Stretch db   sql server 2016 (sn0028)
Stretch db sql server 2016 (sn0028)
 
Auditing Data Access in SQL Server
Auditing Data Access in SQL ServerAuditing Data Access in SQL Server
Auditing Data Access in SQL Server
 
Pre and post tips to installing sql server correctly
Pre and post tips to installing sql server correctlyPre and post tips to installing sql server correctly
Pre and post tips to installing sql server correctly
 
Project 2 Final presentation. December 2016
Project 2 Final presentation. December 2016Project 2 Final presentation. December 2016
Project 2 Final presentation. December 2016
 
Row level security
Row level securityRow level security
Row level security
 
What's New for the BI workload in SharePoint 2016 and SQL Server 2016
What's New for the BI workload in SharePoint 2016 and SQL Server 2016What's New for the BI workload in SharePoint 2016 and SQL Server 2016
What's New for the BI workload in SharePoint 2016 and SQL Server 2016
 
SQL Server 2016 Query store
SQL Server 2016 Query storeSQL Server 2016 Query store
SQL Server 2016 Query store
 
Dynamic data masking sql server 2016
Dynamic data masking sql server 2016Dynamic data masking sql server 2016
Dynamic data masking sql server 2016
 
Live Query Statistics & Query Store in SQL Server 2016
Live Query Statistics & Query Store in SQL Server 2016Live Query Statistics & Query Store in SQL Server 2016
Live Query Statistics & Query Store in SQL Server 2016
 
End-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL ServerEnd-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL Server
 
Building Data Warehouse in SQL Server
Building Data Warehouse in SQL ServerBuilding Data Warehouse in SQL Server
Building Data Warehouse in SQL Server
 
SQL Server - Using Tools to Analyze Query Performance
SQL Server - Using Tools to Analyze Query PerformanceSQL Server - Using Tools to Analyze Query Performance
SQL Server - Using Tools to Analyze Query Performance
 
Exploring sql server 2016
Exploring sql server 2016Exploring sql server 2016
Exploring sql server 2016
 
SQL Server - Querying and Managing XML Data
SQL Server - Querying and Managing XML DataSQL Server - Querying and Managing XML Data
SQL Server - Querying and Managing XML Data
 
How to secure your data in Office 365
How to secure your data in Office 365 How to secure your data in Office 365
How to secure your data in Office 365
 

Ähnlich wie Troubleshooting sql server

Monitor and tune for performance
Monitor and tune for performanceMonitor and tune for performance
Monitor and tune for performance
Steve Xu
 
Managing SQLserver for the reluctant DBA
Managing SQLserver for the reluctant DBAManaging SQLserver for the reluctant DBA
Managing SQLserver for the reluctant DBA
Concentrated Technology
 
Profiling its okay in sql server
Profiling its okay in sql serverProfiling its okay in sql server
Profiling its okay in sql server
unclebiguns
 
SQL Server 2000 Research Series - Architecture Overview
SQL Server 2000 Research Series - Architecture OverviewSQL Server 2000 Research Series - Architecture Overview
SQL Server 2000 Research Series - Architecture Overview
Jerry Yang
 

Ähnlich wie Troubleshooting sql server (20)

Sql server lesson12
Sql server lesson12Sql server lesson12
Sql server lesson12
 
Sql server lesson12
Sql server lesson12Sql server lesson12
Sql server lesson12
 
R12 d49656 gc10-apps dba 07
R12 d49656 gc10-apps dba 07R12 d49656 gc10-apps dba 07
R12 d49656 gc10-apps dba 07
 
Monitor and tune for performance
Monitor and tune for performanceMonitor and tune for performance
Monitor and tune for performance
 
Sql Server
Sql ServerSql Server
Sql Server
 
Introduction to sql database on azure
Introduction to sql database on azureIntroduction to sql database on azure
Introduction to sql database on azure
 
SQL Server and System Center Advisor
SQL Server and System Center AdvisorSQL Server and System Center Advisor
SQL Server and System Center Advisor
 
Managing SQLserver for the reluctant DBA
Managing SQLserver for the reluctant DBAManaging SQLserver for the reluctant DBA
Managing SQLserver for the reluctant DBA
 
Sql Sever Presentation.pptx
Sql Sever Presentation.pptxSql Sever Presentation.pptx
Sql Sever Presentation.pptx
 
Novidades do SQL Server 2016
Novidades do SQL Server 2016Novidades do SQL Server 2016
Novidades do SQL Server 2016
 
Profiling its okay in sql server
Profiling its okay in sql serverProfiling its okay in sql server
Profiling its okay in sql server
 
Sql server-dba
Sql server-dbaSql server-dba
Sql server-dba
 
SQL Server 2000 Research Series - Architecture Overview
SQL Server 2000 Research Series - Architecture OverviewSQL Server 2000 Research Series - Architecture Overview
SQL Server 2000 Research Series - Architecture Overview
 
Web Cloud Computing SQL Server - Ferrara University
Web Cloud Computing SQL Server  -  Ferrara UniversityWeb Cloud Computing SQL Server  -  Ferrara University
Web Cloud Computing SQL Server - Ferrara University
 
Ebook11
Ebook11Ebook11
Ebook11
 
Microsoft SQL Server 2012 Components and Tools (Quick Overview) - Rev 1.3
Microsoft SQL Server 2012 Components and Tools (Quick Overview) - Rev 1.3Microsoft SQL Server 2012 Components and Tools (Quick Overview) - Rev 1.3
Microsoft SQL Server 2012 Components and Tools (Quick Overview) - Rev 1.3
 
Ebook6
Ebook6Ebook6
Ebook6
 
Sql interview question part 6
Sql interview question part 6Sql interview question part 6
Sql interview question part 6
 
Ebook6
Ebook6Ebook6
Ebook6
 
Sql interview-question-part-6
Sql interview-question-part-6Sql interview-question-part-6
Sql interview-question-part-6
 

Mehr von Antonios Chatzipavlis

Mehr von Antonios Chatzipavlis (20)

Data virtualization using polybase
Data virtualization using polybaseData virtualization using polybase
Data virtualization using polybase
 
SQL server Backup Restore Revealed
SQL server Backup Restore RevealedSQL server Backup Restore Revealed
SQL server Backup Restore Revealed
 
Migrate SQL Workloads to Azure
Migrate SQL Workloads to AzureMigrate SQL Workloads to Azure
Migrate SQL Workloads to Azure
 
Machine Learning in SQL Server 2019
Machine Learning in SQL Server 2019Machine Learning in SQL Server 2019
Machine Learning in SQL Server 2019
 
Workload Management in SQL Server 2019
Workload Management in SQL Server 2019Workload Management in SQL Server 2019
Workload Management in SQL Server 2019
 
Loading Data into Azure SQL DW (Synapse Analytics)
Loading Data into Azure SQL DW (Synapse Analytics)Loading Data into Azure SQL DW (Synapse Analytics)
Loading Data into Azure SQL DW (Synapse Analytics)
 
Introduction to DAX Language
Introduction to DAX LanguageIntroduction to DAX Language
Introduction to DAX Language
 
Building diagnostic queries using DMVs and DMFs
Building diagnostic queries using DMVs and DMFs Building diagnostic queries using DMVs and DMFs
Building diagnostic queries using DMVs and DMFs
 
Exploring T-SQL Anti-Patterns
Exploring T-SQL Anti-Patterns Exploring T-SQL Anti-Patterns
Exploring T-SQL Anti-Patterns
 
Designing a modern data warehouse in azure
Designing a modern data warehouse in azure   Designing a modern data warehouse in azure
Designing a modern data warehouse in azure
 
Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019
 
Designing a modern data warehouse in azure
Designing a modern data warehouse in azure   Designing a modern data warehouse in azure
Designing a modern data warehouse in azure
 
SQLServer Database Structures
SQLServer Database Structures SQLServer Database Structures
SQLServer Database Structures
 
Sqlschool 2017 recap - 2018 plans
Sqlschool 2017 recap - 2018 plansSqlschool 2017 recap - 2018 plans
Sqlschool 2017 recap - 2018 plans
 
Azure SQL Database for the SQL Server DBA - Azure Bootcamp Athens 2018
Azure SQL Database for the SQL Server DBA - Azure Bootcamp Athens 2018 Azure SQL Database for the SQL Server DBA - Azure Bootcamp Athens 2018
Azure SQL Database for the SQL Server DBA - Azure Bootcamp Athens 2018
 
Microsoft SQL Family and GDPR
Microsoft SQL Family and GDPRMicrosoft SQL Family and GDPR
Microsoft SQL Family and GDPR
 
Statistics and Indexes Internals
Statistics and Indexes InternalsStatistics and Indexes Internals
Statistics and Indexes Internals
 
Introduction to Azure Data Lake
Introduction to Azure Data LakeIntroduction to Azure Data Lake
Introduction to Azure Data Lake
 
Azure SQL Data Warehouse
Azure SQL Data Warehouse Azure SQL Data Warehouse
Azure SQL Data Warehouse
 
Introduction to azure document db
Introduction to azure document dbIntroduction to azure document db
Introduction to azure document db
 

Kürzlich hochgeladen

Kürzlich hochgeladen (20)

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
 
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
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 

Troubleshooting sql server

  • 1. C H A P T E R Troubleshooting SQL Server Athens Oct 23, 2015
  • 2. Presenter introduction  1982 - I have been started with computers.  1988 - I started my professional carrier in computers industry.  1996 - I have been started to work with SQL Server version 6.0  1998 - I earned my first certification at Microsoft as Microsoft Certified Solution Developer (3rd in Greece) and started my carrier as Microsoft Certified Trainer (MCT) with more than 25.000 hours of training until now!  2010 - I became for first time Microsoft MVP on SQL Server I created the SQL School Greece (www.sqlschool.gr)  2012 - I became MCT Regional Lead by Microsoft Learning Program.  2013 - I was certified as MCSE : Data Platform, MCSE : Business Intelligence Antonios Chatzipavlis Database Architect SQL Server Evangelist MCT, MCSE, MCITP, MCPD, MCSD, MCDBA, MCSA, MCTS, MCAD, MCP, OCA, ITIL-F
  • 3. Follow us in social media Twitter : @antoniosch / @sqlschool Facebook : fb/sqlschoolgr YouTube : yt/user/achatzipavlis LinkedIn : SQL School Greece group
  • 5. Presentation outline 01: SQL Server Monitoring Overview 02: SQL Server Threading Model 03: Using Wait Statistics 04: Using Extended Events 05: Create your Baseline
  • 6. C H A P T E R 01 SQL Server Monitoring Overview  Why Monitor?  Guidelines for Monitoring  Monitoring Tools for SQL Server
  • 7. Why Monitor?  Diagnosing causes of performance issues  Response Time  Throughput of the system  Detecting and resolving concurrency issues  SQL Server uses locks to ensure data consistency.  Identifying changing trends in resource utilization  Capacity planning to identify the required hardware resources to support the database workload.  It is important to monitor resource utilization changes
  • 8. Guidelines for Monitoring  Understand the workloads you need to support  Every workload has different requirements  You need to understand its workloads so that you can identify the relevant metrics to monitor  Prioritize resources based on the importance of each workload to the business  Establish a baseline  A common mistake is to wait until there is a problem before monitoring the SQL Server solution  A better approach is to identify the key metrics that your workloads rely on, and record baseline values for these metrics when the system is operating normally  Monitor regularly to track changes in key metrics.  It is generally better to proactively monitor the system on a regular basis to identify any trends that signify changes in the way the workloads consume resources.  With this approach, you can plan server upgrades or application optimizations before they become critical.
  • 9. Monitoring Tools for SQL Server Build in and External Tools Activity Monitor A component of SQL Server Management Studio that enables DBAs to view details of current activity in the database engine Dynamic Management View and Functions Database objects that provide insight into internal SQL Server operations Performance Monitor A windows administrative tool that you can use to record values for multiple performance counters over a period of time, and analyze results in a variety of chart SQL Server Profiler A tracing and profiling tool that you can use to record details of Transact-SQL and other events in a SQL Server workload. We can replay or use it as a source for tuning SQL Trace A lightweight, Transact-SQL based programming interface for tracing SQL Server activity
  • 10. Monitoring Tools for SQL Server Build in and External Tools Database Engine Tuning Advisor A tool provided with SQL Server for tuning indexes and statistics based on a known workload SQL Server Utility Control Point A centralized management portal for monitoring server health for multiple instances based on specific collection sets SQL Server Extended Events A lightweight eventing architecture. SQL Server Data Collection An automated system for collecting and storing and reporting performance data for multiple SQL Server instances Distributed Replay An advanced tool for replaying workloads across a potentially distributed set of servers
  • 11. Monitoring Tools for SQL Server Build in and External Tools Microsoft System Center Operations Manager An enterprise-wide infrastructure management solution that uses management packs to collect performance and health data from Windows and application services SqlDiag Tool The SQLdiag utility is a general purpose diagnostics collection utility that can be run as a console application or as a service sp_WhoIsActive Provides detailed information about all of the sessions running on your SQL Server system, including what they’re doing and how they’re impacting server behavior sp_Blitz SQL Server health and warning check Performance Monitor Windows Performance Monitor is an operating system tool that brings together several previously disparate performance and monitoring tool
  • 12. Monitoring Tools for SQL Server SQL Server 2016 Query Store An enterprise-wide infrastructure management solution that uses management packs to collect performance and health data from Windows and application services Live Query Stats Windows Performance Monitor is an operating system tool that brings together several previously disparate performance and monitoring tool
  • 13. C H A P T E R 02 SQL Server Threading Model  Introduction  What a thread is  Thread Scheduling  SQL Server Schedulers  Thread States  The Waiter List  The Runnable Queue
  • 14. Introduction  SQL Server is an OS on Windows OS  It performs and controls its own:  Memory management  I/O  Scheduling
  • 15. What a thread is  A thread is unit of execution within a process  Multiple threads can exist within a process  Each is given small amount of processor time  Waits while other threads execute (called scheduling)  SQL Server uses OS threads to perform its work  Called worker threads  Dedicated threads exists  Such as for performing checkpoints, deadlock monitoring, and ghost record cleanup  Most are in a pool of threads that SQL Server uses to process user requests (Working Threads)
  • 16. Thread Scheduling  SQL Server has its own thread scheduling  Called non-preemptive scheduling  Is more efficient than Windows scheduling  Performed by the SQLOS layer of the Storage Engine  Each processor core (logical or physical) has a scheduler  A scheduler is responsible for managing the execution of work by threads  Schedulers exist for user threads and for internal operations  Use the sys.dm_os_schedulers DMV to view schedulers
  • 17. SQL Server Schedulers Processor Runnable Queue Waiter List One scheduler per logical or physical processor core Plus some extra ones for internal tasks and the DAC
  • 18. Thread States  RUNNING  The thread is currently executing on the processor  SUSPENDED  The thread is currently on the Waiter List waiting for a resource  RUNNABLE  The thread is currently on the Runnable Queue waiting to execute on the processor
  • 19. The Waiter List  Is an unordered list of threads that are suspended  Any thread can be notified at any time that the resource it is waiting for is now available  No time limit for a thread on the waiter list  Although execution timeouts or lock timeouts may take effect  No limit on the number of threads on waiter list  The sys.dm_os_waiting_tasks DMV  Shows which threads are currently waiting and what they are waiting for
  • 20. The Runnable Queue  Is a strict First-In-First-Out (FIFO) queue  Resource Governor exception  The sys.dm_os_schedulers DMV shows the size of the Runnable Queue in Runnable_tasks_count column
  • 22. C H A P T E R 03 Using Wait Statistics  Waits and Queues  Wait Times  DMVs for Waits
  • 23. Waits and Queues  Waits  Wait is when a thread that's running on the processor cannot proceed because it needs a resource and the resource that it needs is not available  The thread state changed from RUNNING to SUSPENDED  Moved to Waiter List and remains on the list until it became available  Queues  Is a generic term and means what's stopping the thread being able to get its resource  PAGEIOLATCH_XX : The I/O subsystem need to complete the I/O  LCK_M_XX : Another thread holding an incompatible lock  CXPACKET : Another thread needs to complete its portion of work
  • 24. Wait Times Wait time=Resource Wait time + Signal Wait time  Wait time  Is the time spent from when a thread is running on the processor (RUNNING) moved to the Waiter List (SUSPENDED) and is being signaled and moving back onto the runnable queue (RUNNABLE) and is going back to running  Resource Wait time  Time spent on the Waiter List with state SUSPENDED  Signal Wait time  Time spent on the Runnable Queue with state RUNNABLE
  • 25. DMVs for Waits  sys.dm_os_waiting_tasks  Shows all threads that are currently suspended  Think of it as the ‘what is happening right now?’ view of a server  The first thing to run when approaching a ‘slow’ server  sys.dm_os_wait_stats  Shows aggregated wait statistics for all wait types  Aggregated since the server started or the wait statistics were cleared  Some math is required to make the results useful  Calculating the resource wait time  Calculating the average times rather than the total times
  • 27. C H A P T E R 04 Using Extended Events  Why Extended Events?  Switch from SQL Trace to Xevents  Extended Events Architecture  Event Life Cycle  Targets
  • 28. Why Extended Events?  It’s the FUTURE  SQL Trace is a deprecated feature in SQL Server 2012  This makes understanding XE crucial to supporting SQL Server in the future  Less overhead  Lightweight to minimize impact  Provides minimum schema of data that is specific to the event being fired  Events are filtered early in the firing lifecycle based on the predicates  Flexibility and Power  Allows complex configurations for event collection that simplify problem identification.  Many events in more recent releases
  • 29. Switch from SQL Trace to XEvents  Events Mapping Query  Column to Action Mapping Query select xe.xe_event_name,st.name from sys.trace_xe_event_map as xe inner join sys.trace_events as st on xe.trace_event_id = st.trace_event_id; select xe.xe_action_name, tc.name from sys.trace_xe_action_map as xe inner join sys.trace_columns as tc on xe.trace_column_id = tc.trace_column_id;
  • 30. Extended Events Architecture  Sessions  Are a functional boundary for configuration of events  Events  Correspond to well-know points of code  Predicates  Boolean expressions that define the conditions required for an event to actually fire  Actions  Actions only execute after predicate evaluation determines the event will fire  Targets  Targets are event consumers
  • 31. Event Life Cycle Event point encountered in code Is Event Enabled in a session Code Continues Buffer Data for Asynchronus Targets Send to Synchronous Targets Immediately Execute Actions and Collect data (if applicable) Are there configurable columns Collect non-configurable column data Passes Filter Criteria (Predicate) Collect Configurable Column data No No Yes Yes Yes
  • 32. Targets  Event counter  Counts all specified events that occur during an Extended Events session.  Use to obtain information about workload characteristics without adding the overhead of full event collection.  This is a synchronous target.  Event file  Use to write event session output from complete memory buffers to disk.  This is an asynchronous target.
  • 33. Targets  Event pairing  Many kinds of events occur in pairs, such as lock acquires and lock releases.  Use to determine when a specified paired event does not occur in a matched set.  This is an asynchronous target.  Event Tracing for Windows (ETW)  Use to correlate SQL Server events with Windows operating system or application event data.  This is a synchronous target.
  • 34. Targets  Histogram  Use to count the number of times that a specified event occurs, based on a specified event column or action.  This is an asynchronous target.  Ring buffer  Use to hold the event data in memory on a first-in first-out (FIFO) basis, or on a per-event FIFO basis.  This is an asynchronous target.
  • 35. Use case scenarios of Extended Events 04
  • 36. C H A P T E R 05 Create your Baseline
  • 38. Summary  SQL Server Monitoring Overview  SQL Server Threading Model  Using Wait Statistics  Using Extended Events  Create your Baseline