SlideShare a Scribd company logo
1 of 15
SQL Server
Performance Troubleshooting
Dan Andrei STEFAN
Database Administrator
Synygy Europa
09.05.2013
Resource Bottlenecks
vs.
CPU
What can lead to high CPU usage?
• excessive compilation / recompilation
sys.dm_exec_query_optimizer_info
– statistics changes
– unparametrized queries
alter database {} set parameterization forced
Oracle equivalent: cursor_sharing=force
• hash / sort operators
sys.dm_db_task_space_usage
Oracle equivalent: v$sort_usage
• queries that consume cpu time
sys.dm_exec_query_stats
Oracle equivalent: v$sqlstats
• 3rd party applications / services on db server
CPU Tip
• How to compute the CPU % per request?
sys.dm_os_threads
Memory
What can lead to high memory usage or memory pressure?
• Large table / index scans
• Large sorts
• Cached plans for unparametrized queries
• High value for OS available memory
• Memory leaks
• 3rd party applications / services on db server
Memory Pressure
Memory Tip
I/O
What can lead to I/O bottlenecks?
• Missing indexes
• Full Table Scan / Clustered Index Scan
• Memory pressure
• Large sort operations placed on tempdb
• Poor storage infrastructure / IO subsystem
• high values for read/write latency
• Partitions not being aligned
• 3rd party applications / services on db server
I/O Tip
• How to find the HoBT on which sessions are waiting?
sys.dm_os_waiting_tasks
• Identify on what is page on what the transaction is currently waiting
• get page details
• query for object name
Network
What can lead to network bottlenecks?
• Mirroring (High Safety Mode)
• Network card / driver
– Check ProcessorInterruptsSec counter
• Network infrastructure
– switches, routers, firewalls
– Bandwidth
• DoS
tempdb
What can lead to tempdb bottlenecks?
sys.dm_db_file_space_usage
• Memory pressure
• temporary user tables
• Large sorts runs / work files for hash join
• Version store size
• Improper number of files
– not 1 file / cpu core, sometime it is too much (16 cores -> 16 files?!)
– SGAM, GAM, PFS contention
– Round robin allocation mechanism
Parallelism
Up to what level parallelism is good?
• DOP gives the number of threads per parallel operator
– 0 (default) means CPU count
– I’ve seen queries running with 81, 73, 58 threads on an 8 CPUs machine
• Too many threads
– Low CPU usage
– High values of CXPACKET
– High values of Context Switches
– Spinlocks
Slow running queries
Knowing about resources, what make a query slow?
• Improper statistics, leading to improper execution plan
Nested loops vs. hash join
• Improper join/filter conditions, leading to huge /very low cardinality
estimations
Histograms in SQL Server 2000/2005/2008 are only built for a single column—the first column in the set of key columns of
the statistics object.
• Missing indexes
sys.dm_db_missing_index_groups mig / sys.dm_db_missing_index_group_stats / sys.dm_db_missing_index_details
• Too many threads open
• Waits (I/O, memory, CPU, locks)
sys.dm_os_waiting_tasks
• and many, many others
SQL Profiler - demo
• Hopefully, it will work 
Remember Windows 95 presentation?
Thank you
• Slide 6 again?

More Related Content

What's hot

Webinar: Capacity Planning
Webinar: Capacity PlanningWebinar: Capacity Planning
Webinar: Capacity PlanningMongoDB
 
071410 sun a_1515_feldman_stephen
071410 sun a_1515_feldman_stephen071410 sun a_1515_feldman_stephen
071410 sun a_1515_feldman_stephenSteve Feldman
 
505 kobal exadata
505 kobal exadata505 kobal exadata
505 kobal exadataKam Chan
 
Operating Systems - Virtual Memory
Operating Systems - Virtual MemoryOperating Systems - Virtual Memory
Operating Systems - Virtual MemoryDamian T. Gordon
 
Web Performance & Scalability Tools
Web Performance & Scalability ToolsWeb Performance & Scalability Tools
Web Performance & Scalability ToolsFolio3 Software
 
Virtual Memory Management
Virtual Memory ManagementVirtual Memory Management
Virtual Memory Managementprimeteacher32
 
10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQL10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQLPostgreSQL-Consulting
 
Dbms by jeet goyal
Dbms by jeet goyalDbms by jeet goyal
Dbms by jeet goyaljeet1991
 
Memory Hierarchy Design, Basics, Cache Optimization, Address Translation
Memory Hierarchy Design, Basics, Cache Optimization, Address TranslationMemory Hierarchy Design, Basics, Cache Optimization, Address Translation
Memory Hierarchy Design, Basics, Cache Optimization, Address TranslationFarwa Ansari
 
Virtual memory
Virtual memoryVirtual memory
Virtual memoryAsif Iqbal
 
IMC Summit 2016 Breakout - Andy Pavlo - What Non-Volatile Memory Means for th...
IMC Summit 2016 Breakout - Andy Pavlo - What Non-Volatile Memory Means for th...IMC Summit 2016 Breakout - Andy Pavlo - What Non-Volatile Memory Means for th...
IMC Summit 2016 Breakout - Andy Pavlo - What Non-Volatile Memory Means for th...In-Memory Computing Summit
 
basics of virtual memory
basics of virtual memorybasics of virtual memory
basics of virtual memoryAdarsh Patel
 
COMPUTER ARCHITECTURE AND ORGANISTAION
COMPUTER ARCHITECTURE AND ORGANISTAIONCOMPUTER ARCHITECTURE AND ORGANISTAION
COMPUTER ARCHITECTURE AND ORGANISTAIONUttam Singh
 
GFS - Google File System
GFS - Google File SystemGFS - Google File System
GFS - Google File Systemtutchiio
 
2013 year of real-time hadoop
2013 year of real-time hadoop2013 year of real-time hadoop
2013 year of real-time hadoopGeoff Hendrey
 
Managing and Configuring Databases
Managing and Configuring DatabasesManaging and Configuring Databases
Managing and Configuring DatabasesRam Kedem
 
Chapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryChapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryWayne Jones Jnr
 
Cache optimization
Cache optimizationCache optimization
Cache optimizationKavi Kathir
 
Hw09 Low Latency, Random Reads From Hdfs
Hw09   Low Latency, Random Reads From HdfsHw09   Low Latency, Random Reads From Hdfs
Hw09 Low Latency, Random Reads From HdfsCloudera, Inc.
 

What's hot (20)

Webinar: Capacity Planning
Webinar: Capacity PlanningWebinar: Capacity Planning
Webinar: Capacity Planning
 
071410 sun a_1515_feldman_stephen
071410 sun a_1515_feldman_stephen071410 sun a_1515_feldman_stephen
071410 sun a_1515_feldman_stephen
 
505 kobal exadata
505 kobal exadata505 kobal exadata
505 kobal exadata
 
Operating Systems - Virtual Memory
Operating Systems - Virtual MemoryOperating Systems - Virtual Memory
Operating Systems - Virtual Memory
 
Web Performance & Scalability Tools
Web Performance & Scalability ToolsWeb Performance & Scalability Tools
Web Performance & Scalability Tools
 
Virtual Memory Management
Virtual Memory ManagementVirtual Memory Management
Virtual Memory Management
 
10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQL10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQL
 
141060753008 3715302
141060753008 3715302141060753008 3715302
141060753008 3715302
 
Dbms by jeet goyal
Dbms by jeet goyalDbms by jeet goyal
Dbms by jeet goyal
 
Memory Hierarchy Design, Basics, Cache Optimization, Address Translation
Memory Hierarchy Design, Basics, Cache Optimization, Address TranslationMemory Hierarchy Design, Basics, Cache Optimization, Address Translation
Memory Hierarchy Design, Basics, Cache Optimization, Address Translation
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
IMC Summit 2016 Breakout - Andy Pavlo - What Non-Volatile Memory Means for th...
IMC Summit 2016 Breakout - Andy Pavlo - What Non-Volatile Memory Means for th...IMC Summit 2016 Breakout - Andy Pavlo - What Non-Volatile Memory Means for th...
IMC Summit 2016 Breakout - Andy Pavlo - What Non-Volatile Memory Means for th...
 
basics of virtual memory
basics of virtual memorybasics of virtual memory
basics of virtual memory
 
COMPUTER ARCHITECTURE AND ORGANISTAION
COMPUTER ARCHITECTURE AND ORGANISTAIONCOMPUTER ARCHITECTURE AND ORGANISTAION
COMPUTER ARCHITECTURE AND ORGANISTAION
 
GFS - Google File System
GFS - Google File SystemGFS - Google File System
GFS - Google File System
 
2013 year of real-time hadoop
2013 year of real-time hadoop2013 year of real-time hadoop
2013 year of real-time hadoop
 
Managing and Configuring Databases
Managing and Configuring DatabasesManaging and Configuring Databases
Managing and Configuring Databases
 
Chapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryChapter 9 - Virtual Memory
Chapter 9 - Virtual Memory
 
Cache optimization
Cache optimizationCache optimization
Cache optimization
 
Hw09 Low Latency, Random Reads From Hdfs
Hw09   Low Latency, Random Reads From HdfsHw09   Low Latency, Random Reads From Hdfs
Hw09 Low Latency, Random Reads From Hdfs
 

Similar to Dba lounge-sql server-performance-troubleshooting

(ATS6-PLAT06) Maximizing AEP Performance
(ATS6-PLAT06) Maximizing AEP Performance(ATS6-PLAT06) Maximizing AEP Performance
(ATS6-PLAT06) Maximizing AEP PerformanceBIOVIA
 
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 1sqlserver.co.il
 
Hardware Provisioning
Hardware ProvisioningHardware Provisioning
Hardware ProvisioningMongoDB
 
Investigate SQL Server Memory Like Sherlock Holmes
Investigate SQL Server Memory Like Sherlock HolmesInvestigate SQL Server Memory Like Sherlock Holmes
Investigate SQL Server Memory Like Sherlock HolmesRichard Douglas
 
Meta scale kognitio hadoop webinar
Meta scale kognitio hadoop webinarMeta scale kognitio hadoop webinar
Meta scale kognitio hadoop webinarKognitio
 
MongoDB Capacity Planning
MongoDB Capacity PlanningMongoDB Capacity Planning
MongoDB Capacity PlanningNorberto Leite
 
(ATS4-PLAT08) Server Pool Management
(ATS4-PLAT08) Server Pool Management(ATS4-PLAT08) Server Pool Management
(ATS4-PLAT08) Server Pool ManagementBIOVIA
 
hbaseconasia2019 Phoenix Improvements and Practices on Cloud HBase at Alibaba
hbaseconasia2019 Phoenix Improvements and Practices on Cloud HBase at Alibabahbaseconasia2019 Phoenix Improvements and Practices on Cloud HBase at Alibaba
hbaseconasia2019 Phoenix Improvements and Practices on Cloud HBase at AlibabaMichael Stack
 
ApacheCon2010: Cache & Concurrency Considerations in Cassandra (& limits of JVM)
ApacheCon2010: Cache & Concurrency Considerations in Cassandra (& limits of JVM)ApacheCon2010: Cache & Concurrency Considerations in Cassandra (& limits of JVM)
ApacheCon2010: Cache & Concurrency Considerations in Cassandra (& limits of JVM)srisatish ambati
 
HDFS_architecture.ppt
HDFS_architecture.pptHDFS_architecture.ppt
HDFS_architecture.pptvijayapraba1
 
Strata London 2019 Scaling Impala.pptx
Strata London 2019 Scaling Impala.pptxStrata London 2019 Scaling Impala.pptx
Strata London 2019 Scaling Impala.pptxManish Maheshwari
 
Capacity Planning For Your Growing MongoDB Cluster
Capacity Planning For Your Growing MongoDB ClusterCapacity Planning For Your Growing MongoDB Cluster
Capacity Planning For Your Growing MongoDB ClusterMongoDB
 
Right-Sizing your SQL Server Virtual Machine
Right-Sizing your SQL Server Virtual MachineRight-Sizing your SQL Server Virtual Machine
Right-Sizing your SQL Server Virtual Machineheraflux
 
Modeling, estimating, and predicting Ceph (Linux Foundation - Vault 2015)
Modeling, estimating, and predicting Ceph (Linux Foundation - Vault 2015)Modeling, estimating, and predicting Ceph (Linux Foundation - Vault 2015)
Modeling, estimating, and predicting Ceph (Linux Foundation - Vault 2015)Lars Marowsky-Brée
 

Similar to Dba lounge-sql server-performance-troubleshooting (20)

(ATS6-PLAT06) Maximizing AEP Performance
(ATS6-PLAT06) Maximizing AEP Performance(ATS6-PLAT06) Maximizing AEP Performance
(ATS6-PLAT06) Maximizing AEP Performance
 
Big Data for QAs
Big Data for QAsBig Data for QAs
Big Data for QAs
 
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
 
Hardware Provisioning
Hardware ProvisioningHardware Provisioning
Hardware Provisioning
 
Investigate SQL Server Memory Like Sherlock Holmes
Investigate SQL Server Memory Like Sherlock HolmesInvestigate SQL Server Memory Like Sherlock Holmes
Investigate SQL Server Memory Like Sherlock Holmes
 
Meta scale kognitio hadoop webinar
Meta scale kognitio hadoop webinarMeta scale kognitio hadoop webinar
Meta scale kognitio hadoop webinar
 
MongoDB Capacity Planning
MongoDB Capacity PlanningMongoDB Capacity Planning
MongoDB Capacity Planning
 
Performance tuning in sql server
Performance tuning in sql serverPerformance tuning in sql server
Performance tuning in sql server
 
(ATS4-PLAT08) Server Pool Management
(ATS4-PLAT08) Server Pool Management(ATS4-PLAT08) Server Pool Management
(ATS4-PLAT08) Server Pool Management
 
hbaseconasia2019 Phoenix Improvements and Practices on Cloud HBase at Alibaba
hbaseconasia2019 Phoenix Improvements and Practices on Cloud HBase at Alibabahbaseconasia2019 Phoenix Improvements and Practices on Cloud HBase at Alibaba
hbaseconasia2019 Phoenix Improvements and Practices on Cloud HBase at Alibaba
 
ApacheCon2010: Cache & Concurrency Considerations in Cassandra (& limits of JVM)
ApacheCon2010: Cache & Concurrency Considerations in Cassandra (& limits of JVM)ApacheCon2010: Cache & Concurrency Considerations in Cassandra (& limits of JVM)
ApacheCon2010: Cache & Concurrency Considerations in Cassandra (& limits of JVM)
 
08 operating system support
08 operating system support08 operating system support
08 operating system support
 
HDFS_architecture.ppt
HDFS_architecture.pptHDFS_architecture.ppt
HDFS_architecture.ppt
 
Drupal performance
Drupal performanceDrupal performance
Drupal performance
 
Strata London 2019 Scaling Impala.pptx
Strata London 2019 Scaling Impala.pptxStrata London 2019 Scaling Impala.pptx
Strata London 2019 Scaling Impala.pptx
 
Capacity Planning For Your Growing MongoDB Cluster
Capacity Planning For Your Growing MongoDB ClusterCapacity Planning For Your Growing MongoDB Cluster
Capacity Planning For Your Growing MongoDB Cluster
 
Capacityplanning
Capacityplanning Capacityplanning
Capacityplanning
 
Right-Sizing your SQL Server Virtual Machine
Right-Sizing your SQL Server Virtual MachineRight-Sizing your SQL Server Virtual Machine
Right-Sizing your SQL Server Virtual Machine
 
Modeling, estimating, and predicting Ceph (Linux Foundation - Vault 2015)
Modeling, estimating, and predicting Ceph (Linux Foundation - Vault 2015)Modeling, estimating, and predicting Ceph (Linux Foundation - Vault 2015)
Modeling, estimating, and predicting Ceph (Linux Foundation - Vault 2015)
 
Cassandra Core Concepts
Cassandra Core ConceptsCassandra Core Concepts
Cassandra Core Concepts
 

Dba lounge-sql server-performance-troubleshooting

  • 1. SQL Server Performance Troubleshooting Dan Andrei STEFAN Database Administrator Synygy Europa 09.05.2013
  • 3. CPU What can lead to high CPU usage? • excessive compilation / recompilation sys.dm_exec_query_optimizer_info – statistics changes – unparametrized queries alter database {} set parameterization forced Oracle equivalent: cursor_sharing=force • hash / sort operators sys.dm_db_task_space_usage Oracle equivalent: v$sort_usage • queries that consume cpu time sys.dm_exec_query_stats Oracle equivalent: v$sqlstats • 3rd party applications / services on db server
  • 4. CPU Tip • How to compute the CPU % per request? sys.dm_os_threads
  • 5. Memory What can lead to high memory usage or memory pressure? • Large table / index scans • Large sorts • Cached plans for unparametrized queries • High value for OS available memory • Memory leaks • 3rd party applications / services on db server
  • 8. I/O What can lead to I/O bottlenecks? • Missing indexes • Full Table Scan / Clustered Index Scan • Memory pressure • Large sort operations placed on tempdb • Poor storage infrastructure / IO subsystem • high values for read/write latency • Partitions not being aligned • 3rd party applications / services on db server
  • 9. I/O Tip • How to find the HoBT on which sessions are waiting? sys.dm_os_waiting_tasks • Identify on what is page on what the transaction is currently waiting • get page details • query for object name
  • 10. Network What can lead to network bottlenecks? • Mirroring (High Safety Mode) • Network card / driver – Check ProcessorInterruptsSec counter • Network infrastructure – switches, routers, firewalls – Bandwidth • DoS
  • 11. tempdb What can lead to tempdb bottlenecks? sys.dm_db_file_space_usage • Memory pressure • temporary user tables • Large sorts runs / work files for hash join • Version store size • Improper number of files – not 1 file / cpu core, sometime it is too much (16 cores -> 16 files?!) – SGAM, GAM, PFS contention – Round robin allocation mechanism
  • 12. Parallelism Up to what level parallelism is good? • DOP gives the number of threads per parallel operator – 0 (default) means CPU count – I’ve seen queries running with 81, 73, 58 threads on an 8 CPUs machine • Too many threads – Low CPU usage – High values of CXPACKET – High values of Context Switches – Spinlocks
  • 13. Slow running queries Knowing about resources, what make a query slow? • Improper statistics, leading to improper execution plan Nested loops vs. hash join • Improper join/filter conditions, leading to huge /very low cardinality estimations Histograms in SQL Server 2000/2005/2008 are only built for a single column—the first column in the set of key columns of the statistics object. • Missing indexes sys.dm_db_missing_index_groups mig / sys.dm_db_missing_index_group_stats / sys.dm_db_missing_index_details • Too many threads open • Waits (I/O, memory, CPU, locks) sys.dm_os_waiting_tasks • and many, many others
  • 14. SQL Profiler - demo • Hopefully, it will work  Remember Windows 95 presentation?