SlideShare a Scribd company logo
DMVs And Performance Monitor
in SQL Server
By
Zeba Tabassum
Agenda
Definition
DMVs Type
DMVs Category
Disadvantage Of DMVs
Performance Monitor
Counters
DMV’s
Definition
Dynamic management views and functions return server state information
that can be used to monitor the health of a server instance, diagnose
problems, and tune performance.
Prior to SQL Server 2005, we had several system tables(for example
sysprocesses, syslockinfo etc.) to monitor the state of the system. Though
these system tables are still available in SQL Server 2005 and in later versions
but SQL Server 2005 introduced whole new set of Dynamic Management
Views
DMV’s Type
There are two types of dynamic management views:-
• Server-scoped DMV’s They reside in master database and provide SQL
Server instance wide information. To access these DMV we need to have
SELECT permission on the objects and VIEW SERVER STATE permission on
the server.
• Database-scoped DMV’s They reside in each database and provide
database wide information. To access these DMV we need to have SELECT
permission on the objects and these require VIEW DATABASE STATE
permission on the database.
Listing DMVs
SELECT name AS DMV_Name,
[type] AS DMV_Type,
type_desc
FROM sys.system_objects
WHERE name LIKE 'dm_%'
ORDER BY name
SELECT count(*) TotalDMVCount
FROM sys.system_objects
WHERE name LIKE 'dm_%'
DMVs
The most frequently used DMV sections are:
• Database
• Execution
• IO
• Index
• SQL operating system
Database DMVs
Sys.dm_db_log_space_usage
sys.dm_db_partition_stats
sys.dm_db_file_space_usage
Sys.dm_db_task_space_usage
Database DMVs
SELECT TOP 3 object_name(object_id) AS objname,
in_row_data_page_count,
in_row_reserved_page_count,
used_page_count,
reserved_page_count,
row_count
FROM sys.dm_db_partition_stats
GO
Execution Related DMVs
• sys.dm_exec_connections
• sys.dm_exec_sessions
• sys.dm_exec_requests
• sys.dm_exec_cached_plans
• sys.dm_exec_query_plans
• sys.dm_exec_sql_text
• sys.dm_exec_query_stats
Execution Related DMVs
SELECT session_id,
login_name,
last_request_end_time,
cpu_time
FROM sys.dm_exec_sessions
WHERE session_id >= 61
GO
Execution Related DMVs
SELECT connection_id,
session_id,
client_net_address,
auth_scheme
FROM sys.dm_exec_connections
WHERE session_id >= 61
I/O Related DMV’s
• sys.dm_io_virtual_file_stats
• sys.dm_io_pending_io_requests
• sys.dm_io_cluster_shared_drives
I/O Related DMV’s
--Shows I/O stats for (data and log files) and virtual files no. of read and write
SELECT *
FROM sys.dm_io_pending_io_requests
GO
SELECT TOP 5 db_name(database_id) DataBaseName,
file_id,
num_of_reads,
num_of_writes
FROM sys.dm_io_virtual_file_stats(NULL, NULL)
Index Related DMVs
• sys.dm_db_index_physical_stats
• sys.dm_db_index_usage_stats
• sys.dm_db_index_operational_stats
• sys.dm_db_missing_index_details
• sys.dm_db_missing_index_groups
• sys.dm_db_missing_index_group_stats
• sys.dm_db_missing_index_columns
Index Related DMVs
--- Returns system_scansCounts with different date and objects
fragmentation of index operations. --
DECLARE @DBName VARCHAR(50)='testnew'
DECLARE @dbid BIGINT-- Database DB Id
SET @dbid=DB_ID(@DBName)
SELECT @DBName AS DataBaseName,
system_scans,
last_system_scan
FROM sys.dm_db_index_usage_stats
WHERE database_id = @dbid
Index Related DMVs
SELECT @DBName AS DataBaseName,
object_id,
avg_fragmentation_in_percent,
fragment_count
FROM sys.dm_db_index_physical_stats (@dbid, NULL, NULL, NULL, NULL)
WHERE database_id = @dbid
AND fragment_count > 0
Operating System Related DMVs
• sys.dm_os_performance_counters
• sys.dm_os_schedulers
• sys.dm_os_nodes
• sys.dm_os_waiting_tasks
• sys.dm_os_wait_stats
Operating System Related DMVs
---Returning cached page count for each database
SELECT COUNT(*)AS cached_pages_count,
db_name(database_id) AS database_name,
database_id
FROM sys.dm_os_buffer_descriptors
WHERE database_id NOT IN ( 32767, 4, 2, 1,3, 5 )
GROUP BY db_name(database_id),
database_id
ORDER BY cached_pages_count DESC;
GO
Operating System Related DMVs
--How memory is used overall on the server, and how much memory is
available
SELECT total_physical_memory_kb,
available_physical_memory_kb,
total_page_file_kb,
system_memory_state_desc
FROM
sys.dm_os_sys_memory
Disadvantages
• The biggest disadvantage in my opinion is the data in the DMVs is reset
upon SQL restart. So if you are trying to do trending type of reports, you'll
need to capture this DMV data on a regular basis to a DW somewhere.
DMV data is not guaranteed to be accurate at the time of retrieval. They
are updated asynchronously.
Performance Monitor
Performance Monitor, commonly referred to as PerfMon, is a Microsoft
Windows utility that allows us to capture :-
statistical information about the hardware environment, operating system,
and any applications that expose properties and counters.
We will learn how to use System Monitor to gather counters into counter
logs, which can be used to troubleshoot system and performance issues.
There are five major resource areas that can cause bottlenecks and affect
server performance:
physical disk,
memory,
process,
CPU, and
Network
If any of these resources are overutilized, your server or application can
become noticeably slow or can even crash.
Performance Counters
LogicalDisk% Free Space
This measures the percentage of free space on the selected logical disk drive.
Take note if this falls below 15 percent, you risk running out of free space for
the OS to store critical files. One obvious solution here is to add more disk
space.
PhysicalDisk% Idle Time
This measures the percentage of time the disk was idle during the sample interval. If
this counter falls below 20 percent, the disk system is saturated. You may consider
replacing the current disk system with a faster disk system.
Disk Counters
PhysicalDiskAvg. Disk Sec/Read :This measures the average time, in seconds,
to read data from the disk.
PhysicalDiskAvg. Disk Sec/Write:This measures the average time, in seconds,
it takes to write data to the disk.
PhysicalDiskAvg. Disk Queue Length :
This indicates how many I/O operations are waiting for the hard drive to
become available. If the value here is larger than the two times the number of
spindles, that means the disk itself may be the bottleneck.
Memory Counters
MemoryCache Bytes :This indicates the amount of memory being used for
the file system cache. There may be a disk bottleneck if this value is greater
than 300MB.
Memory% Committed Bytes in Use:This measures the ratio of Committed
Bytes to the Commit Limit—in other words, the amount of virtual memory in
use. This indicates insufficient memory if the number is greater than 80
percent. The obvious solution for this is to add more memory.
MemoryAvailable Mbytes:This measures the amount of physical memory, in
megabytes, available for running processes. If this value is less than 5 percent
of the total physical RAM, that means there is insufficient memory, and that
can increase paging activity. To resolve this problem, you should simply add
more memory.
MemoryPages per Second :This measures the rate at which pages are read
from or written to disk to resolve hard page faults. If the value is greater than
1,000, as a result of excessive paging, there may be a memory leak.
Processor Counters
Processor% Processor Time:This measures the percentage of elapsed time
the processor spends executing a non-idle thread. If the percentage is greater
than 85 percent, the processor is overwhelmed and the server may require a
faster processor.
Processor% User Time :This measures the percentage of elapsed time the
processor spends in user mode. If this value is high, the server is busy with
the application. One possible solution here is to optimize the application that
is using up the processor resources.
SystemProcessor Queue Length
This indicates the number of threads in the processor queue. The server
doesn't have enough processor power if the value is more than two times the
number of CPUs for an extended period of time.
Network Counters
Network InterfaceBytes Total/Sec :
This measures the rate at which bytes are sent and received over each
network adapter, including framing characters. The network is saturated if
you discover that more than 70 percent of the interface is consumed. For a
100-Mbps NIC, the interface consumed is 8.7MB/sec (100Mbps = 100000kbps
= 12.5MB/sec* 70 percent). In a situation like this, you may want to add a
faster network card or segment the network.
Network InterfaceOutput Queue Length:
This measures the length of the output packet queue, in packets. There is
network saturation if the value is more than 2. You can address this problem
by adding a faster network card or segmenting the network.
SQL Server Counters
SQLServer: General Statistics – User Connections
SQLServer: Memory Manager – Memory Grants Pending
SQLServer: SQL Statistics – Batch Requests/sec
SQLServer: SQL Statistics – Compilations/sec
SQLServer: SQL Statistics – Recompilations/sec
SQLServer:BufferManager - Buffer Cache hit ratio
This is the percentage of requests serviced by data cache. When cache is
properly used, this should be over 90%. The counter can be improved by
adding more RAM.
SQLServer:Databases,
SQL Server Counters
SQLServer:Exec Statistics,
SQLServer:General Statistics,
SQLServer:Latches,
SQLServer:Locks– Average Wait Time
This counter shows the average time needed to acquire a lock. This value needs to
be as low as possible.
SQLServer:MemoryManager– Target Server Memory (KB):
indicates how much memory SQL Server “wants”.
SQLServer:MemoryManager— Total Server Memory (KB):
Indicates how much memory SQL Server is actually using.
SQLServer:PlanCache
SQLServer:Access Methods – Full scans/sec:
higher numbers (> 1 or 2) may mean you are not using indexes and resorting to
table scans instead.

More Related Content

What's hot

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
 
PostgreSQL continuous backup and PITR with Barman
 PostgreSQL continuous backup and PITR with Barman PostgreSQL continuous backup and PITR with Barman
PostgreSQL continuous backup and PITR with Barman
EDB
 
Database performance tuning and query optimization
Database performance tuning and query optimizationDatabase performance tuning and query optimization
Database performance tuning and query optimization
Usman Tariq
 
Database presentation
Database presentationDatabase presentation
Database presentation
webhostingguy
 
Exadata Deployment Bare Metal vs Virtualized
Exadata Deployment Bare Metal vs VirtualizedExadata Deployment Bare Metal vs Virtualized
Exadata Deployment Bare Metal vs Virtualized
Umair Mansoob
 
MySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsMySQL Atchitecture and Concepts
MySQL Atchitecture and Concepts
Tuyen Vuong
 
Oracle archi ppt
Oracle archi pptOracle archi ppt
Oracle archi ppt
Hitesh Kumar Markam
 
SSD Deployment Strategies for MySQL
SSD Deployment Strategies for MySQLSSD Deployment Strategies for MySQL
SSD Deployment Strategies for MySQL
Yoshinori Matsunobu
 
Backup and recovery in oracle
Backup and recovery in oracleBackup and recovery in oracle
Backup and recovery in oracle
sadegh salehi
 
Dbms Introduction and Basics
Dbms Introduction and BasicsDbms Introduction and Basics
Dbms Introduction and Basics
SHIKHA GAUTAM
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
metsarin
 
Cassandra Virtual Node talk
Cassandra Virtual Node talkCassandra Virtual Node talk
Cassandra Virtual Node talk
Patrick McFadin
 
Sql Server Performance Tuning
Sql Server Performance TuningSql Server Performance Tuning
Sql Server Performance Tuning
Bala Subra
 
Running MariaDB in multiple data centers
Running MariaDB in multiple data centersRunning MariaDB in multiple data centers
Running MariaDB in multiple data centers
MariaDB plc
 
DOAG Oracle Database Vault
DOAG Oracle Database VaultDOAG Oracle Database Vault
DOAG Oracle Database Vault
Stefan Oehrli
 
Deep Dive on Amazon Aurora
Deep Dive on Amazon AuroraDeep Dive on Amazon Aurora
Deep Dive on Amazon Aurora
Amazon Web Services
 
MYSQL.ppt
MYSQL.pptMYSQL.ppt
MYSQL.ppt
webhostingguy
 
Introduction to Oracle Database
Introduction to Oracle DatabaseIntroduction to Oracle Database
Introduction to Oracle Database
puja_dhar
 
Less01 architecture
Less01 architectureLess01 architecture
Less01 architecture
Amit Bhalla
 
Database storage engines
Database storage enginesDatabase storage engines
Database storage engines
University of Sindh, Jamshoro
 

What's hot (20)

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
 
PostgreSQL continuous backup and PITR with Barman
 PostgreSQL continuous backup and PITR with Barman PostgreSQL continuous backup and PITR with Barman
PostgreSQL continuous backup and PITR with Barman
 
Database performance tuning and query optimization
Database performance tuning and query optimizationDatabase performance tuning and query optimization
Database performance tuning and query optimization
 
Database presentation
Database presentationDatabase presentation
Database presentation
 
Exadata Deployment Bare Metal vs Virtualized
Exadata Deployment Bare Metal vs VirtualizedExadata Deployment Bare Metal vs Virtualized
Exadata Deployment Bare Metal vs Virtualized
 
MySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsMySQL Atchitecture and Concepts
MySQL Atchitecture and Concepts
 
Oracle archi ppt
Oracle archi pptOracle archi ppt
Oracle archi ppt
 
SSD Deployment Strategies for MySQL
SSD Deployment Strategies for MySQLSSD Deployment Strategies for MySQL
SSD Deployment Strategies for MySQL
 
Backup and recovery in oracle
Backup and recovery in oracleBackup and recovery in oracle
Backup and recovery in oracle
 
Dbms Introduction and Basics
Dbms Introduction and BasicsDbms Introduction and Basics
Dbms Introduction and Basics
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
 
Cassandra Virtual Node talk
Cassandra Virtual Node talkCassandra Virtual Node talk
Cassandra Virtual Node talk
 
Sql Server Performance Tuning
Sql Server Performance TuningSql Server Performance Tuning
Sql Server Performance Tuning
 
Running MariaDB in multiple data centers
Running MariaDB in multiple data centersRunning MariaDB in multiple data centers
Running MariaDB in multiple data centers
 
DOAG Oracle Database Vault
DOAG Oracle Database VaultDOAG Oracle Database Vault
DOAG Oracle Database Vault
 
Deep Dive on Amazon Aurora
Deep Dive on Amazon AuroraDeep Dive on Amazon Aurora
Deep Dive on Amazon Aurora
 
MYSQL.ppt
MYSQL.pptMYSQL.ppt
MYSQL.ppt
 
Introduction to Oracle Database
Introduction to Oracle DatabaseIntroduction to Oracle Database
Introduction to Oracle Database
 
Less01 architecture
Less01 architectureLess01 architecture
Less01 architecture
 
Database storage engines
Database storage enginesDatabase storage engines
Database storage engines
 

Similar to Dmv's & Performance Monitor in SQL Server

Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuning
Jugal Shah
 
Performance tuning in sql server
Performance tuning in sql serverPerformance tuning in sql server
Performance tuning in sql server
Antonios Chatzipavlis
 
Sql server troubleshooting
Sql server troubleshootingSql server troubleshooting
Sql server troubleshooting
Nathan Winters
 
Troubleshooting SQL Server
Troubleshooting SQL ServerTroubleshooting SQL Server
Troubleshooting SQL Server
Stephen Rose
 
Performance Tuning
Performance TuningPerformance Tuning
Performance Tuning
Ligaya Turmelle
 
Sql Server
Sql ServerSql Server
Sql Server
SandyShin
 
Performance Tuning
Performance TuningPerformance Tuning
Performance Tuning
Jannet Peetz
 
Sql server lesson13
Sql server lesson13Sql server lesson13
Sql server lesson13
Ala Qunaibi
 
SQL Server ASYNC_NETWORK_IO Wait Type Explained
SQL Server ASYNC_NETWORK_IO Wait Type ExplainedSQL Server ASYNC_NETWORK_IO Wait Type Explained
SQL Server ASYNC_NETWORK_IO Wait Type Explained
Confio Software
 
Performance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL DatabasePerformance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL Database
Tung Nguyen Thanh
 
http://www.hfadeel.com/Blog/?p=151
http://www.hfadeel.com/Blog/?p=151http://www.hfadeel.com/Blog/?p=151
http://www.hfadeel.com/Blog/?p=151
xlight
 
Sql server performance tuning and optimization
Sql server performance tuning and optimizationSql server performance tuning and optimization
Sql server performance tuning and optimization
Manish Rawat
 
IRJET - The 3-Level Database Architectural Design for OLAP and OLTP Ops
IRJET - The 3-Level Database Architectural Design for OLAP and OLTP OpsIRJET - The 3-Level Database Architectural Design for OLAP and OLTP Ops
IRJET - The 3-Level Database Architectural Design for OLAP and OLTP Ops
IRJET Journal
 
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
 
How should I monitor my idaa
How should I monitor my idaaHow should I monitor my idaa
How should I monitor my idaa
Cuneyt Goksu
 
Quick guide to PostgreSQL Performance Tuning
Quick guide to PostgreSQL Performance TuningQuick guide to PostgreSQL Performance Tuning
Quick guide to PostgreSQL Performance Tuning
Ron Morgan
 
Sap basis made_easy321761331053730
Sap basis made_easy321761331053730Sap basis made_easy321761331053730
Sap basis made_easy321761331053730
K Hari Shankar
 
Movile Internet Movel SA: A Change of Seasons: A big move to Apache Cassandra
Movile Internet Movel SA: A Change of Seasons: A big move to Apache CassandraMovile Internet Movel SA: A Change of Seasons: A big move to Apache Cassandra
Movile Internet Movel SA: A Change of Seasons: A big move to Apache Cassandra
DataStax Academy
 
Cassandra Summit 2015 - A Change of Seasons
Cassandra Summit 2015 - A Change of SeasonsCassandra Summit 2015 - A Change of Seasons
Cassandra Summit 2015 - A Change of Seasons
Eiti Kimura
 
Weblogic Cluster performance tuning
Weblogic Cluster performance tuningWeblogic Cluster performance tuning
Weblogic Cluster performance tuning
Aditya Bhuyan
 

Similar to Dmv's & Performance Monitor in SQL Server (20)

Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuning
 
Performance tuning in sql server
Performance tuning in sql serverPerformance tuning in sql server
Performance tuning in sql server
 
Sql server troubleshooting
Sql server troubleshootingSql server troubleshooting
Sql server troubleshooting
 
Troubleshooting SQL Server
Troubleshooting SQL ServerTroubleshooting SQL Server
Troubleshooting SQL Server
 
Performance Tuning
Performance TuningPerformance Tuning
Performance Tuning
 
Sql Server
Sql ServerSql Server
Sql Server
 
Performance Tuning
Performance TuningPerformance Tuning
Performance Tuning
 
Sql server lesson13
Sql server lesson13Sql server lesson13
Sql server lesson13
 
SQL Server ASYNC_NETWORK_IO Wait Type Explained
SQL Server ASYNC_NETWORK_IO Wait Type ExplainedSQL Server ASYNC_NETWORK_IO Wait Type Explained
SQL Server ASYNC_NETWORK_IO Wait Type Explained
 
Performance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL DatabasePerformance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL Database
 
http://www.hfadeel.com/Blog/?p=151
http://www.hfadeel.com/Blog/?p=151http://www.hfadeel.com/Blog/?p=151
http://www.hfadeel.com/Blog/?p=151
 
Sql server performance tuning and optimization
Sql server performance tuning and optimizationSql server performance tuning and optimization
Sql server performance tuning and optimization
 
IRJET - The 3-Level Database Architectural Design for OLAP and OLTP Ops
IRJET - The 3-Level Database Architectural Design for OLAP and OLTP OpsIRJET - The 3-Level Database Architectural Design for OLAP and OLTP Ops
IRJET - The 3-Level Database Architectural Design for OLAP and OLTP Ops
 
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
 
How should I monitor my idaa
How should I monitor my idaaHow should I monitor my idaa
How should I monitor my idaa
 
Quick guide to PostgreSQL Performance Tuning
Quick guide to PostgreSQL Performance TuningQuick guide to PostgreSQL Performance Tuning
Quick guide to PostgreSQL Performance Tuning
 
Sap basis made_easy321761331053730
Sap basis made_easy321761331053730Sap basis made_easy321761331053730
Sap basis made_easy321761331053730
 
Movile Internet Movel SA: A Change of Seasons: A big move to Apache Cassandra
Movile Internet Movel SA: A Change of Seasons: A big move to Apache CassandraMovile Internet Movel SA: A Change of Seasons: A big move to Apache Cassandra
Movile Internet Movel SA: A Change of Seasons: A big move to Apache Cassandra
 
Cassandra Summit 2015 - A Change of Seasons
Cassandra Summit 2015 - A Change of SeasonsCassandra Summit 2015 - A Change of Seasons
Cassandra Summit 2015 - A Change of Seasons
 
Weblogic Cluster performance tuning
Weblogic Cluster performance tuningWeblogic Cluster performance tuning
Weblogic Cluster performance tuning
 

Recently uploaded

一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
ywqeos
 
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
nyfuhyz
 
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
eoxhsaa
 
一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
aqzctr7x
 
Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024
ElizabethGarrettChri
 
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
aguty
 
社内勉強会資料_Hallucination of LLMs               .
社内勉強会資料_Hallucination of LLMs               .社内勉強会資料_Hallucination of LLMs               .
社内勉強会資料_Hallucination of LLMs               .
NABLAS株式会社
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
ihavuls
 
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
nuttdpt
 
Build applications with generative AI on Google Cloud
Build applications with generative AI on Google CloudBuild applications with generative AI on Google Cloud
Build applications with generative AI on Google Cloud
Márton Kodok
 
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
1tyxnjpia
 
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
Timothy Spann
 
一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理
一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理
一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理
slg6lamcq
 
How To Control IO Usage using Resource Manager
How To Control IO Usage using Resource ManagerHow To Control IO Usage using Resource Manager
How To Control IO Usage using Resource Manager
Alireza Kamrani
 
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging DataPredictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Kiwi Creative
 
Sample Devops SRE Product Companies .pdf
Sample Devops SRE  Product Companies .pdfSample Devops SRE  Product Companies .pdf
Sample Devops SRE Product Companies .pdf
Vineet
 
DSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelinesDSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelines
Timothy Spann
 
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
Social Samosa
 
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
taqyea
 
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
Vietnam Cotton & Spinning Association
 

Recently uploaded (20)

一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
 
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
 
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
 
一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
 
Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024
 
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
 
社内勉強会資料_Hallucination of LLMs               .
社内勉強会資料_Hallucination of LLMs               .社内勉強会資料_Hallucination of LLMs               .
社内勉強会資料_Hallucination of LLMs               .
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
 
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
 
Build applications with generative AI on Google Cloud
Build applications with generative AI on Google CloudBuild applications with generative AI on Google Cloud
Build applications with generative AI on Google Cloud
 
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
 
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
 
一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理
一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理
一比一原版南十字星大学毕业证(SCU毕业证书)学历如何办理
 
How To Control IO Usage using Resource Manager
How To Control IO Usage using Resource ManagerHow To Control IO Usage using Resource Manager
How To Control IO Usage using Resource Manager
 
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging DataPredictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
 
Sample Devops SRE Product Companies .pdf
Sample Devops SRE  Product Companies .pdfSample Devops SRE  Product Companies .pdf
Sample Devops SRE Product Companies .pdf
 
DSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelinesDSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelines
 
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
 
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
 
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
 

Dmv's & Performance Monitor in SQL Server

  • 1. DMVs And Performance Monitor in SQL Server By Zeba Tabassum
  • 2. Agenda Definition DMVs Type DMVs Category Disadvantage Of DMVs Performance Monitor Counters
  • 3. DMV’s Definition Dynamic management views and functions return server state information that can be used to monitor the health of a server instance, diagnose problems, and tune performance. Prior to SQL Server 2005, we had several system tables(for example sysprocesses, syslockinfo etc.) to monitor the state of the system. Though these system tables are still available in SQL Server 2005 and in later versions but SQL Server 2005 introduced whole new set of Dynamic Management Views
  • 4. DMV’s Type There are two types of dynamic management views:- • Server-scoped DMV’s They reside in master database and provide SQL Server instance wide information. To access these DMV we need to have SELECT permission on the objects and VIEW SERVER STATE permission on the server. • Database-scoped DMV’s They reside in each database and provide database wide information. To access these DMV we need to have SELECT permission on the objects and these require VIEW DATABASE STATE permission on the database.
  • 5. Listing DMVs SELECT name AS DMV_Name, [type] AS DMV_Type, type_desc FROM sys.system_objects WHERE name LIKE 'dm_%' ORDER BY name SELECT count(*) TotalDMVCount FROM sys.system_objects WHERE name LIKE 'dm_%'
  • 6.
  • 7. DMVs The most frequently used DMV sections are: • Database • Execution • IO • Index • SQL operating system
  • 9. Database DMVs SELECT TOP 3 object_name(object_id) AS objname, in_row_data_page_count, in_row_reserved_page_count, used_page_count, reserved_page_count, row_count FROM sys.dm_db_partition_stats GO
  • 10.
  • 11. Execution Related DMVs • sys.dm_exec_connections • sys.dm_exec_sessions • sys.dm_exec_requests • sys.dm_exec_cached_plans • sys.dm_exec_query_plans • sys.dm_exec_sql_text • sys.dm_exec_query_stats
  • 12. Execution Related DMVs SELECT session_id, login_name, last_request_end_time, cpu_time FROM sys.dm_exec_sessions WHERE session_id >= 61 GO
  • 13. Execution Related DMVs SELECT connection_id, session_id, client_net_address, auth_scheme FROM sys.dm_exec_connections WHERE session_id >= 61
  • 14.
  • 15.
  • 16. I/O Related DMV’s • sys.dm_io_virtual_file_stats • sys.dm_io_pending_io_requests • sys.dm_io_cluster_shared_drives
  • 17. I/O Related DMV’s --Shows I/O stats for (data and log files) and virtual files no. of read and write SELECT * FROM sys.dm_io_pending_io_requests GO SELECT TOP 5 db_name(database_id) DataBaseName, file_id, num_of_reads, num_of_writes FROM sys.dm_io_virtual_file_stats(NULL, NULL)
  • 18.
  • 19. Index Related DMVs • sys.dm_db_index_physical_stats • sys.dm_db_index_usage_stats • sys.dm_db_index_operational_stats • sys.dm_db_missing_index_details • sys.dm_db_missing_index_groups • sys.dm_db_missing_index_group_stats • sys.dm_db_missing_index_columns
  • 20. Index Related DMVs --- Returns system_scansCounts with different date and objects fragmentation of index operations. -- DECLARE @DBName VARCHAR(50)='testnew' DECLARE @dbid BIGINT-- Database DB Id SET @dbid=DB_ID(@DBName) SELECT @DBName AS DataBaseName, system_scans, last_system_scan FROM sys.dm_db_index_usage_stats WHERE database_id = @dbid
  • 21. Index Related DMVs SELECT @DBName AS DataBaseName, object_id, avg_fragmentation_in_percent, fragment_count FROM sys.dm_db_index_physical_stats (@dbid, NULL, NULL, NULL, NULL) WHERE database_id = @dbid AND fragment_count > 0
  • 22.
  • 23.
  • 24. Operating System Related DMVs • sys.dm_os_performance_counters • sys.dm_os_schedulers • sys.dm_os_nodes • sys.dm_os_waiting_tasks • sys.dm_os_wait_stats
  • 25. Operating System Related DMVs ---Returning cached page count for each database SELECT COUNT(*)AS cached_pages_count, db_name(database_id) AS database_name, database_id FROM sys.dm_os_buffer_descriptors WHERE database_id NOT IN ( 32767, 4, 2, 1,3, 5 ) GROUP BY db_name(database_id), database_id ORDER BY cached_pages_count DESC; GO
  • 26. Operating System Related DMVs --How memory is used overall on the server, and how much memory is available SELECT total_physical_memory_kb, available_physical_memory_kb, total_page_file_kb, system_memory_state_desc FROM sys.dm_os_sys_memory
  • 27.
  • 28. Disadvantages • The biggest disadvantage in my opinion is the data in the DMVs is reset upon SQL restart. So if you are trying to do trending type of reports, you'll need to capture this DMV data on a regular basis to a DW somewhere. DMV data is not guaranteed to be accurate at the time of retrieval. They are updated asynchronously.
  • 29. Performance Monitor Performance Monitor, commonly referred to as PerfMon, is a Microsoft Windows utility that allows us to capture :- statistical information about the hardware environment, operating system, and any applications that expose properties and counters. We will learn how to use System Monitor to gather counters into counter logs, which can be used to troubleshoot system and performance issues.
  • 30. There are five major resource areas that can cause bottlenecks and affect server performance: physical disk, memory, process, CPU, and Network If any of these resources are overutilized, your server or application can become noticeably slow or can even crash.
  • 31. Performance Counters LogicalDisk% Free Space This measures the percentage of free space on the selected logical disk drive. Take note if this falls below 15 percent, you risk running out of free space for the OS to store critical files. One obvious solution here is to add more disk space. PhysicalDisk% Idle Time This measures the percentage of time the disk was idle during the sample interval. If this counter falls below 20 percent, the disk system is saturated. You may consider replacing the current disk system with a faster disk system.
  • 32. Disk Counters PhysicalDiskAvg. Disk Sec/Read :This measures the average time, in seconds, to read data from the disk. PhysicalDiskAvg. Disk Sec/Write:This measures the average time, in seconds, it takes to write data to the disk. PhysicalDiskAvg. Disk Queue Length : This indicates how many I/O operations are waiting for the hard drive to become available. If the value here is larger than the two times the number of spindles, that means the disk itself may be the bottleneck.
  • 33. Memory Counters MemoryCache Bytes :This indicates the amount of memory being used for the file system cache. There may be a disk bottleneck if this value is greater than 300MB. Memory% Committed Bytes in Use:This measures the ratio of Committed Bytes to the Commit Limit—in other words, the amount of virtual memory in use. This indicates insufficient memory if the number is greater than 80 percent. The obvious solution for this is to add more memory.
  • 34. MemoryAvailable Mbytes:This measures the amount of physical memory, in megabytes, available for running processes. If this value is less than 5 percent of the total physical RAM, that means there is insufficient memory, and that can increase paging activity. To resolve this problem, you should simply add more memory. MemoryPages per Second :This measures the rate at which pages are read from or written to disk to resolve hard page faults. If the value is greater than 1,000, as a result of excessive paging, there may be a memory leak.
  • 35. Processor Counters Processor% Processor Time:This measures the percentage of elapsed time the processor spends executing a non-idle thread. If the percentage is greater than 85 percent, the processor is overwhelmed and the server may require a faster processor. Processor% User Time :This measures the percentage of elapsed time the processor spends in user mode. If this value is high, the server is busy with the application. One possible solution here is to optimize the application that is using up the processor resources. SystemProcessor Queue Length This indicates the number of threads in the processor queue. The server doesn't have enough processor power if the value is more than two times the number of CPUs for an extended period of time.
  • 36. Network Counters Network InterfaceBytes Total/Sec : This measures the rate at which bytes are sent and received over each network adapter, including framing characters. The network is saturated if you discover that more than 70 percent of the interface is consumed. For a 100-Mbps NIC, the interface consumed is 8.7MB/sec (100Mbps = 100000kbps = 12.5MB/sec* 70 percent). In a situation like this, you may want to add a faster network card or segment the network. Network InterfaceOutput Queue Length: This measures the length of the output packet queue, in packets. There is network saturation if the value is more than 2. You can address this problem by adding a faster network card or segmenting the network.
  • 37. SQL Server Counters SQLServer: General Statistics – User Connections SQLServer: Memory Manager – Memory Grants Pending SQLServer: SQL Statistics – Batch Requests/sec SQLServer: SQL Statistics – Compilations/sec SQLServer: SQL Statistics – Recompilations/sec SQLServer:BufferManager - Buffer Cache hit ratio This is the percentage of requests serviced by data cache. When cache is properly used, this should be over 90%. The counter can be improved by adding more RAM. SQLServer:Databases,
  • 38. SQL Server Counters SQLServer:Exec Statistics, SQLServer:General Statistics, SQLServer:Latches, SQLServer:Locks– Average Wait Time This counter shows the average time needed to acquire a lock. This value needs to be as low as possible. SQLServer:MemoryManager– Target Server Memory (KB): indicates how much memory SQL Server “wants”. SQLServer:MemoryManager— Total Server Memory (KB): Indicates how much memory SQL Server is actually using. SQLServer:PlanCache SQLServer:Access Methods – Full scans/sec: higher numbers (> 1 or 2) may mean you are not using indexes and resorting to table scans instead.