SlideShare a Scribd company logo
Ing. Eduardo Castro, PhD
ecastro@grupoasesor.net

http://ComunidadWindows.org
Session Objectives:
  Get familiar with database performance tuning
  tools, especially what SQL Server 2008 offers
  Understand methodology of database
  performance bottleneck analysis
  Learn features/improvements of SQL Server
  2008 that help improve performance
Target the most challenging and innovative
SQL Server applications

10+ TB DW, 3k/tran/s OLTP, Large 500GB+ Cubes, Competitive migrations,
Complex deployments, Server Consolidation (1000+)


Invest in large scale, referenceable SQL Server projects
across the world
    Provide SQLCAT technical & project experience
    Conduct architecture and design reviews covering performance,
    operation, scalability and availability
    Offer use of HW lab in Redmond with direct access to SQL Server
    development team
Performance Tuning Tools
I/O Bottleneck
CPU Bottleneck
Memory Bottleneck
System Performance Monitor (Perfmon)
SQL Profiler Trace
Dynamic Management Views/Functions
DBCC commands
SQLDiag (Shipped with SQL 2005/2008)
SQLIO, SQLIOSim
KernRate
Debugging tools (Windbg, DebugDiag,…)
More…
Data Collector & Management Data
Warehouse (MDW)
Extended Events
Activity Monitor
New DMVs/DMFs
MDW Host



                                   MDW         Client Workstation
     Target Server                Snapshot
                                    Data




                 dcexec.exe                  Management Studio
   SSIS
   Pkgs
                     Cache
Collection Set                                    MDW
  Metadata            Files
                                                 Reports
Job Metadata
                 SQL Agent
   msdb
Time line




Navigation
 control



Resource
 usage
Highly scalable with low overhead
Future of SQL tracing
Built-in system_health session
select event_session_id, name, startup_state from
sys.server_event_sessions

Session definition example
create event session session_error on server
    ADD EVENT sqlserver.error_reported
             (action (sqlserver.sql_text, sqlserver.tsql_stack,
    sqlserver.client_app_name)
             where error = 50001)
    ADD target package0.ring_buffer
    with (max_dispatch_latency = 1 seconds)
go
alter event session session_error on server state = start;
go
Ajuste (tuning) del rendimiento de SQL Server 2008
Memory allocation tracking
   sys.dm_os_memory_brokers
   sys.dm_os_memory_nodes
Reqource Governor
   sys.dm_resource_governor_configuration
   sys.dm_resource_governor_resource_pools
   sys.dm_resource_governor_workload_groups
Query performance (hash value for query and plan)
   sys.dm_exec_query_stats
  Sys.dm_exec_requests
  sys.dm_exec_procedure_stats
  sys.dm_exec_trigger_stats
More…
Bottleneck – A point or component of a
process where throughput is the slowest.
Understanding where time is spent
Elapsed Time = Running + Waiting
Key is the waiting - what type of wait(s)?
Monitor and identify I/O bottleneck
  Resource Monitor & Performance Monitor
  MDW
  DMV & Extended Events
What is driving high I/O load?
  Inefficient query plan
  Too much data to read/write
  Slow I/O subsystem
File level I/O
  throughput
    and disk
response time
Runtime
Performance
 monitoring




  System
  Reports




What counters
 to look at?
Physical Disk Object:
   Avg. Disk Queue Length
   Avg. Disk Sec/Read
   Avg. Disk Sec/Write
   %Disk Time
   Disk Transfers/Sec
   Avg. Disk Bytes/Read
   Avg. Disk Bytes/Write
   Disk Read Bytes/Sec
   Disk Write Bytes/Sec
SQL Server Buffer Manager Object: (memory
pressure could cause I/O pressure)
   Buffer Cache hit ratio
   Page Life Expectancy
   Checkpoint pages/sec
   Lazywrites/sec
Page I/O waits
in Buffer pool




WriteLog and
 LogBuffer
    waits
High I/O Latch    sys.dm_os_wait_stats
  Wait Time       sys.dm_exec_requests




pending/stalled   sys.dm_io_pending_io_requests
     I/O          sys.dm_io_virtual_file_stats




 ERRORLOG                                         This is
                  15 second delay in IO
warnings of I/O   completion                      way too
    delays                                        slow
sqlos package                                              sqlserver package

•   async_io_requested                                    •   physical_page_read
•   async_io_completed                                    •   physical_page_write
•   wait_info                                             •   file_read
•   wait_info_external                                    •   file_write
                                                          •   long_io_detected



        2009-04-13 18:30:10.170 spid5s        SQL Server has encountered 1
        occurrence(s) of I/O requests taking longer than 15 seconds to complete on file
        [T:tempdbtemplog.ldf] in database [tempdb] (2). The OS file handle is
        0x0000000000000670. The offset of the latest long I/O is: 0x000007eecac000
        king longer than 15 seconds to complete on file [e:myslowdb.mdf] in database
        [myslowdb] (1). The OS file handle is
        0x00000438. The offset of the latest long IO is: 0x000000513ce000
Look if there is memory pressure
Further narrow down to what queries are
generating the I/O workload. Tune these
queries.
Explore data compression to reduce I/O
load
Upgrade storage hardware
Compress tables/indexes to reduce
database size
Compression ratio depends on schema &
data distribution (avg 50-60%)
Reduce query runtime I/O (increase cpu)
Identify compression candidates
  sp_estimate_data_compression_savings
  sys.dm_db_index_operational_stats
Ajuste (tuning) del rendimiento de SQL Server 2008
Sustained %Processor Time > 80%
  Performance Monitor/Task Manager
  MDW Server Activity Report
  DMV & Extended Events
What is driving high CPU?
  Recompilations
  Cursors
  Inefficient query plans
  More…
Resource          • Monitor it Live
Monitor/Task Manager

Performance Monitor     • Watch Live or Log
      Counters            counters you like

System Data Collector   • Formatted Perfmon
      Reports             counter based report

Windows Performance     • Dig deeper using ETW
   Toolkit (XPerf)
Processor object:
   %Privileged Time
   %Processor Time                New in SQL Server
                                  2008 for Resource
   %User Time                      Governor feature
Process object (SQL Server):
   %Privileged Time
   %Processor Time
   %User Time
SQL Server:Workload Group Stats
   CPU usage %
   Max request cpu time
SQL Server:Resource Pool Stats
   CPU usage %
   CPU usage target %
SQL Server:SQL Statistics
  Batch requests/sec
  SQL Compilations/sec
  SQL Re-Compilations/sec
SQL Server:Cursor Manager by Type
SQL Server:Cursor Manager Total

                                 Concurrent
                            processing of multiple
                            cursors could be cpu
                                  intensive
Total CPU
  waits




CPU cycles
that did the
 real work



  Wait in
 runnable
  queue




  Thread
voluntarily
  yields
sys.dm_exec_query_stats
Sys.dm_exec_sessions   sys.dm_exec_requests   sys.dm_exec_procedure_stats   Sys.sysprocesses
                                                sys.dm_exec_trigger_stats




      cpu_time               cpu_time            total_worker_time
                                                                                   cpu




 total_scheduled_tim
          e
                         total_elapsed_time     total_elapsed_time



                                                                               Backward
                                                                            compatibility view
                                                Sql_handle/query_h
  total_elapsed_time        query_hash
                                                       ash
sqlos package                                                 sqlserver package

•scheduler_monitor_non_yielding_ring_buffer_recorded            •sql_statement_completed
•spinlock_backoff                                               •sp_statement_completed
•Wait_info                                                      •cursor_manager_cursor_end
•wait_info_external                                             •checkpoint_end




              Extended Event can track individual statement level events like Profiler does
              with minimal impact -
              ADD EVENT sqlserver.sql_statement_completed
                                        (action (sqlserver.sql_text)
                                        WHERE duration > 0),
                            ADD EVENT sqlserver.sp_statement_completed
                                        (action (sqlserver.sql_text)
                                        WHERE duration > 0)

              select top 10
              CONVERT(xml, event_data).value('(/event/data/value)[4]','int') as 'cpu'
High cpu doesn’t necessarily mean it’s a
problem.
Drill down to specific workload and queries
that drive cpu usage. Tune them.
Use Resource Governor to protect high
priority workloads
Upgrade hardware
Resource Governor
  allocate cpu/memory to prioritized workloads
  based on connection string parameters
  Mixed workloads: OLTP, Reporting,
  Maintenance
Soft Numa
  Node configuration (soft numa node and cpu
  affinity)
  Network Configuration (soft numa node and tcp
  port)
Ajuste (tuning) del rendimiento de SQL Server 2008
Monitor and identify memory pressure
  Performance Monitor/Task Manager
  MDW Server Activity Report
  DMV & Extended Events
What is eating up my memory?
  External or internal memory pressure
  Inefficient query plan (hashing, sorting,…)
AWE
   32-bit uses AWE to cache data/index pages
   64-bit uses AWE to implement “Locked pages
   in memory”


 Environment                 Virtual Address   Max physical
                             Space             memory
 32-bit on 32-bit OS         2 GB              64 GB
 32-bit on 64-bit OS (Wow)   4 GB              64 GB
 64-bit on 64-bit OS         8 TB              2 TB
Perfmon is golden tool to identify memory
pressure
Memory object:
   Available K/M bytes
   Commit Limit
   Paging File %Usage (Peak)
   Page reads/sec
Process object:
   Private bytes
   Virtual bytes
   Working set
SQL Server Memory Manager object:
    Connection Memory
    Lock Memory                         Somebody is waiting on
    Optimizer Memory                          memory
    Memory Grants Pending
    …
SQL Server Buffer Manager object:
    Buffer cache hit ratio
    Checkpoint pages/sec
    Free list stalls/sec
    Free pages
    Lazy writes/sec
    Page life expectancy                 How long will the page
    Stolen pages                                 live?
    Target pages
    Total pages
SQL Server Plan Cache object
SQL Server Resource Pool Stats object
Query execution waits on
  memory for sorting,
       hashing,…
DBCC MEMORYSTATUS
sys.dm_os_sys_memory
  system_memory_state_desc a good
  indicator of available physical memory
sys.dm_os_process_memory
  process_physical_memory_low = 1
  indicates low physical memory.
  memory_utilization_percentage value below
  100% indicates external memory pressure.
sys.dm_os_memory_clerks
sys.dm_os_ring_buffers
  RING_BUFFER_SCHEDULER_MONITOR
  RING_BUFFER_RESOURCE_MONITOR
  RING_BUFFER_OOM
  RING_BUFFER_MEMORY_BROKER
  RING_BUFFER_BUFFER_POOL
sqlos package                          sqlserver package

• page_heap_memory_allocated             • sort_memory_grant_adjustment
• page_heap_memory_freed                 • plan_cache_cache_hit
• memory_node_oom_ring_buffer_recorded   • plan_cache_cache_attempt
                                         • cursor_manager_cursor_memory_usage




          2009-04-14 09:27:15.43 spid62 Failed allocate
          pages: FAIL_PAGE_ALLOCATION 1
Check memory configuration – sp_configure
External memory pressure – Identify what
other processes are competing
Internal memory pressure – Identify which
SQL component is main consumer
Workload/query tuning (sorting, hash join…)
Resource Governor
Hardware upgrade
Ajuste (tuning) del rendimiento de SQL Server 2008
Focus on methodology – no guess
Correlate data points from multiple tools
Performance tuning is iterative process –
bottleneck could move
Resource contention impacts each other
  Lack of memory -> high cpu & I/O
  Slow I/O -> tempdb contention
  …
Ing. Eduardo Castro, PhD
ecastro@grupoasesor.net
“Troubleshooting Performance Problems in SQL Server
2008” http://msdn.microsoft.com/en-
us/library/dd672789.aspx

More Related Content

PDF
Master MCSA Administración de SQL Server 2012
PDF
Best Practices SQL 2005 SSIS
PDF
Postgres the hardway
PPTX
PDF
KoprowskiT_it_camp2013 - 2amADisasterJustBegan
PDF
MySQL 5.7 milestone
PDF
Introduction to ClustrixDB
PPTX
The SQL Stack Design And Configurations
Master MCSA Administración de SQL Server 2012
Best Practices SQL 2005 SSIS
Postgres the hardway
KoprowskiT_it_camp2013 - 2amADisasterJustBegan
MySQL 5.7 milestone
Introduction to ClustrixDB
The SQL Stack Design And Configurations

What's hot (13)

PDF
Maxscale_메뉴얼
PDF
[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale by ...
PDF
KoprowskiT_SQLSat219_Kiev_2AM-aDisasterJustbegan
DOCX
Mater,slave on mysql
DOCX
Upgrading mysql version 5.5.30 to 5.6.10
PDF
MySQL Advanced Administrator 2021 - 네오클로바
PPTX
PostGreSQL Performance Tuning
PDF
MySQL Backup and Security Best Practices
PDF
SQL Server ASYNC_NETWORK_IO Wait Type Explained
DOCX
My sql storage engines
PDF
Analyzing SQL Server wait stats, hands-on!
PPT
Introduction to Threading in .Net
PDF
Introduction Mysql
Maxscale_메뉴얼
[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale by ...
KoprowskiT_SQLSat219_Kiev_2AM-aDisasterJustbegan
Mater,slave on mysql
Upgrading mysql version 5.5.30 to 5.6.10
MySQL Advanced Administrator 2021 - 네오클로바
PostGreSQL Performance Tuning
MySQL Backup and Security Best Practices
SQL Server ASYNC_NETWORK_IO Wait Type Explained
My sql storage engines
Analyzing SQL Server wait stats, hands-on!
Introduction to Threading in .Net
Introduction Mysql
Ad

Similar to Ajuste (tuning) del rendimiento de SQL Server 2008 (20)

PPTX
Sql server performance tuning
PPTX
It Depends
PPTX
PASS VC: SQL Server Performance Monitoring and Baselining
PPTX
It Depends - Database admin for developers - Rev 20151205
PPTX
Investigate SQL Server Memory Like Sherlock Holmes
PPT
Ms sql server architecture
PPT
Sql server performance tuning and optimization
PDF
2013 Collaborate - OAUG - Presentation
PPTX
Sql Server
PPTX
SQL Server - High availability
PDF
Back2 Basic Tools
PDF
Back 2 basics - SSMS Tips (IDf)
PDF
How should I monitor my idaa
PDF
Ebs dba con4696_pdf_4696_0001
PPTX
Developing on SQL Azure
PDF
SQL Server Tuning to Improve Database Performance
PDF
6 tips for improving ruby performance
PPSX
Oracle Performance Tuning Fundamentals
ODP
Performance Tuning
PDF
Sherlock holmes for dba’s
Sql server performance tuning
It Depends
PASS VC: SQL Server Performance Monitoring and Baselining
It Depends - Database admin for developers - Rev 20151205
Investigate SQL Server Memory Like Sherlock Holmes
Ms sql server architecture
Sql server performance tuning and optimization
2013 Collaborate - OAUG - Presentation
Sql Server
SQL Server - High availability
Back2 Basic Tools
Back 2 basics - SSMS Tips (IDf)
How should I monitor my idaa
Ebs dba con4696_pdf_4696_0001
Developing on SQL Azure
SQL Server Tuning to Improve Database Performance
6 tips for improving ruby performance
Oracle Performance Tuning Fundamentals
Performance Tuning
Sherlock holmes for dba’s
Ad

More from Eduardo Castro (20)

PPTX
Introducción a polybase en SQL Server
PPTX
Creando tu primer ambiente de AI en Azure ML y SQL Server
PPTX
Seguridad en SQL Azure
PPTX
Azure Synapse Analytics MLflow
PPTX
SQL Server 2019 con Windows Server 2022
PPTX
Novedades en SQL Server 2022
PPTX
Introduccion a SQL Server 2022
PPTX
Machine Learning con Azure Managed Instance
PPTX
Novedades en sql server 2022
PDF
Sql server 2019 con windows server 2022
PDF
Introduccion a databricks
PDF
Pronosticos con sql server
PDF
Data warehouse con azure synapse analytics
PPTX
Que hay de nuevo en el Azure Data Lake Storage Gen2
PPTX
Introduccion a Azure Synapse Analytics
PPTX
Seguridad de SQL Database en Azure
PPTX
Python dentro de SQL Server
PDF
Servicios Cognitivos de de Microsoft
TXT
Script de paso a paso de configuración de Secure Enclaves
PDF
Introducción a conceptos de SQL Server Secure Enclaves
Introducción a polybase en SQL Server
Creando tu primer ambiente de AI en Azure ML y SQL Server
Seguridad en SQL Azure
Azure Synapse Analytics MLflow
SQL Server 2019 con Windows Server 2022
Novedades en SQL Server 2022
Introduccion a SQL Server 2022
Machine Learning con Azure Managed Instance
Novedades en sql server 2022
Sql server 2019 con windows server 2022
Introduccion a databricks
Pronosticos con sql server
Data warehouse con azure synapse analytics
Que hay de nuevo en el Azure Data Lake Storage Gen2
Introduccion a Azure Synapse Analytics
Seguridad de SQL Database en Azure
Python dentro de SQL Server
Servicios Cognitivos de de Microsoft
Script de paso a paso de configuración de Secure Enclaves
Introducción a conceptos de SQL Server Secure Enclaves

Recently uploaded (20)

PPTX
Tartificialntelligence_presentation.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
August Patch Tuesday
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Empathic Computing: Creating Shared Understanding
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
Machine learning based COVID-19 study performance prediction
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Getting Started with Data Integration: FME Form 101
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
A Presentation on Artificial Intelligence
PPTX
Spectroscopy.pptx food analysis technology
PDF
Approach and Philosophy of On baking technology
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Tartificialntelligence_presentation.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
MIND Revenue Release Quarter 2 2025 Press Release
A comparative study of natural language inference in Swahili using monolingua...
Mobile App Security Testing_ A Comprehensive Guide.pdf
August Patch Tuesday
Network Security Unit 5.pdf for BCA BBA.
Empathic Computing: Creating Shared Understanding
Heart disease approach using modified random forest and particle swarm optimi...
Machine learning based COVID-19 study performance prediction
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Encapsulation_ Review paper, used for researhc scholars
cloud_computing_Infrastucture_as_cloud_p
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Getting Started with Data Integration: FME Form 101
Accuracy of neural networks in brain wave diagnosis of schizophrenia
A Presentation on Artificial Intelligence
Spectroscopy.pptx food analysis technology
Approach and Philosophy of On baking technology
Build a system with the filesystem maintained by OSTree @ COSCUP 2025

Ajuste (tuning) del rendimiento de SQL Server 2008

  • 1. Ing. Eduardo Castro, PhD [email protected] http://ComunidadWindows.org
  • 2. Session Objectives: Get familiar with database performance tuning tools, especially what SQL Server 2008 offers Understand methodology of database performance bottleneck analysis Learn features/improvements of SQL Server 2008 that help improve performance
  • 3. Target the most challenging and innovative SQL Server applications 10+ TB DW, 3k/tran/s OLTP, Large 500GB+ Cubes, Competitive migrations, Complex deployments, Server Consolidation (1000+) Invest in large scale, referenceable SQL Server projects across the world Provide SQLCAT technical & project experience Conduct architecture and design reviews covering performance, operation, scalability and availability Offer use of HW lab in Redmond with direct access to SQL Server development team
  • 4. Performance Tuning Tools I/O Bottleneck CPU Bottleneck Memory Bottleneck
  • 5. System Performance Monitor (Perfmon) SQL Profiler Trace Dynamic Management Views/Functions DBCC commands SQLDiag (Shipped with SQL 2005/2008) SQLIO, SQLIOSim KernRate Debugging tools (Windbg, DebugDiag,…) More…
  • 6. Data Collector & Management Data Warehouse (MDW) Extended Events Activity Monitor New DMVs/DMFs
  • 7. MDW Host MDW Client Workstation Target Server Snapshot Data dcexec.exe Management Studio SSIS Pkgs Cache Collection Set MDW Metadata Files Reports Job Metadata SQL Agent msdb
  • 9. Highly scalable with low overhead Future of SQL tracing
  • 10. Built-in system_health session select event_session_id, name, startup_state from sys.server_event_sessions Session definition example create event session session_error on server ADD EVENT sqlserver.error_reported (action (sqlserver.sql_text, sqlserver.tsql_stack, sqlserver.client_app_name) where error = 50001) ADD target package0.ring_buffer with (max_dispatch_latency = 1 seconds) go alter event session session_error on server state = start; go
  • 12. Memory allocation tracking sys.dm_os_memory_brokers sys.dm_os_memory_nodes Reqource Governor sys.dm_resource_governor_configuration sys.dm_resource_governor_resource_pools sys.dm_resource_governor_workload_groups Query performance (hash value for query and plan) sys.dm_exec_query_stats Sys.dm_exec_requests sys.dm_exec_procedure_stats sys.dm_exec_trigger_stats More…
  • 13. Bottleneck – A point or component of a process where throughput is the slowest. Understanding where time is spent Elapsed Time = Running + Waiting Key is the waiting - what type of wait(s)?
  • 14. Monitor and identify I/O bottleneck Resource Monitor & Performance Monitor MDW DMV & Extended Events What is driving high I/O load? Inefficient query plan Too much data to read/write Slow I/O subsystem
  • 15. File level I/O throughput and disk response time
  • 16. Runtime Performance monitoring System Reports What counters to look at?
  • 17. Physical Disk Object: Avg. Disk Queue Length Avg. Disk Sec/Read Avg. Disk Sec/Write %Disk Time Disk Transfers/Sec Avg. Disk Bytes/Read Avg. Disk Bytes/Write Disk Read Bytes/Sec Disk Write Bytes/Sec SQL Server Buffer Manager Object: (memory pressure could cause I/O pressure) Buffer Cache hit ratio Page Life Expectancy Checkpoint pages/sec Lazywrites/sec
  • 18. Page I/O waits in Buffer pool WriteLog and LogBuffer waits
  • 19. High I/O Latch sys.dm_os_wait_stats Wait Time sys.dm_exec_requests pending/stalled sys.dm_io_pending_io_requests I/O sys.dm_io_virtual_file_stats ERRORLOG This is 15 second delay in IO warnings of I/O completion way too delays slow
  • 20. sqlos package sqlserver package • async_io_requested • physical_page_read • async_io_completed • physical_page_write • wait_info • file_read • wait_info_external • file_write • long_io_detected 2009-04-13 18:30:10.170 spid5s SQL Server has encountered 1 occurrence(s) of I/O requests taking longer than 15 seconds to complete on file [T:tempdbtemplog.ldf] in database [tempdb] (2). The OS file handle is 0x0000000000000670. The offset of the latest long I/O is: 0x000007eecac000 king longer than 15 seconds to complete on file [e:myslowdb.mdf] in database [myslowdb] (1). The OS file handle is 0x00000438. The offset of the latest long IO is: 0x000000513ce000
  • 21. Look if there is memory pressure Further narrow down to what queries are generating the I/O workload. Tune these queries. Explore data compression to reduce I/O load Upgrade storage hardware
  • 22. Compress tables/indexes to reduce database size Compression ratio depends on schema & data distribution (avg 50-60%) Reduce query runtime I/O (increase cpu) Identify compression candidates sp_estimate_data_compression_savings sys.dm_db_index_operational_stats
  • 24. Sustained %Processor Time > 80% Performance Monitor/Task Manager MDW Server Activity Report DMV & Extended Events What is driving high CPU? Recompilations Cursors Inefficient query plans More…
  • 25. Resource • Monitor it Live Monitor/Task Manager Performance Monitor • Watch Live or Log Counters counters you like System Data Collector • Formatted Perfmon Reports counter based report Windows Performance • Dig deeper using ETW Toolkit (XPerf)
  • 26. Processor object: %Privileged Time %Processor Time New in SQL Server 2008 for Resource %User Time Governor feature Process object (SQL Server): %Privileged Time %Processor Time %User Time SQL Server:Workload Group Stats CPU usage % Max request cpu time SQL Server:Resource Pool Stats CPU usage % CPU usage target %
  • 27. SQL Server:SQL Statistics Batch requests/sec SQL Compilations/sec SQL Re-Compilations/sec SQL Server:Cursor Manager by Type SQL Server:Cursor Manager Total Concurrent processing of multiple cursors could be cpu intensive
  • 28. Total CPU waits CPU cycles that did the real work Wait in runnable queue Thread voluntarily yields
  • 29. sys.dm_exec_query_stats Sys.dm_exec_sessions sys.dm_exec_requests sys.dm_exec_procedure_stats Sys.sysprocesses sys.dm_exec_trigger_stats cpu_time cpu_time total_worker_time cpu total_scheduled_tim e total_elapsed_time total_elapsed_time Backward compatibility view Sql_handle/query_h total_elapsed_time query_hash ash
  • 30. sqlos package sqlserver package •scheduler_monitor_non_yielding_ring_buffer_recorded •sql_statement_completed •spinlock_backoff •sp_statement_completed •Wait_info •cursor_manager_cursor_end •wait_info_external •checkpoint_end Extended Event can track individual statement level events like Profiler does with minimal impact - ADD EVENT sqlserver.sql_statement_completed (action (sqlserver.sql_text) WHERE duration > 0), ADD EVENT sqlserver.sp_statement_completed (action (sqlserver.sql_text) WHERE duration > 0) select top 10 CONVERT(xml, event_data).value('(/event/data/value)[4]','int') as 'cpu'
  • 31. High cpu doesn’t necessarily mean it’s a problem. Drill down to specific workload and queries that drive cpu usage. Tune them. Use Resource Governor to protect high priority workloads Upgrade hardware
  • 32. Resource Governor allocate cpu/memory to prioritized workloads based on connection string parameters Mixed workloads: OLTP, Reporting, Maintenance Soft Numa Node configuration (soft numa node and cpu affinity) Network Configuration (soft numa node and tcp port)
  • 34. Monitor and identify memory pressure Performance Monitor/Task Manager MDW Server Activity Report DMV & Extended Events What is eating up my memory? External or internal memory pressure Inefficient query plan (hashing, sorting,…)
  • 35. AWE 32-bit uses AWE to cache data/index pages 64-bit uses AWE to implement “Locked pages in memory” Environment Virtual Address Max physical Space memory 32-bit on 32-bit OS 2 GB 64 GB 32-bit on 64-bit OS (Wow) 4 GB 64 GB 64-bit on 64-bit OS 8 TB 2 TB
  • 36. Perfmon is golden tool to identify memory pressure Memory object: Available K/M bytes Commit Limit Paging File %Usage (Peak) Page reads/sec Process object: Private bytes Virtual bytes Working set
  • 37. SQL Server Memory Manager object: Connection Memory Lock Memory Somebody is waiting on Optimizer Memory memory Memory Grants Pending … SQL Server Buffer Manager object: Buffer cache hit ratio Checkpoint pages/sec Free list stalls/sec Free pages Lazy writes/sec Page life expectancy How long will the page Stolen pages live? Target pages Total pages SQL Server Plan Cache object SQL Server Resource Pool Stats object
  • 38. Query execution waits on memory for sorting, hashing,…
  • 39. DBCC MEMORYSTATUS sys.dm_os_sys_memory system_memory_state_desc a good indicator of available physical memory sys.dm_os_process_memory process_physical_memory_low = 1 indicates low physical memory. memory_utilization_percentage value below 100% indicates external memory pressure. sys.dm_os_memory_clerks
  • 40. sys.dm_os_ring_buffers RING_BUFFER_SCHEDULER_MONITOR RING_BUFFER_RESOURCE_MONITOR RING_BUFFER_OOM RING_BUFFER_MEMORY_BROKER RING_BUFFER_BUFFER_POOL
  • 41. sqlos package sqlserver package • page_heap_memory_allocated • sort_memory_grant_adjustment • page_heap_memory_freed • plan_cache_cache_hit • memory_node_oom_ring_buffer_recorded • plan_cache_cache_attempt • cursor_manager_cursor_memory_usage 2009-04-14 09:27:15.43 spid62 Failed allocate pages: FAIL_PAGE_ALLOCATION 1
  • 42. Check memory configuration – sp_configure External memory pressure – Identify what other processes are competing Internal memory pressure – Identify which SQL component is main consumer Workload/query tuning (sorting, hash join…) Resource Governor Hardware upgrade
  • 44. Focus on methodology – no guess Correlate data points from multiple tools Performance tuning is iterative process – bottleneck could move Resource contention impacts each other Lack of memory -> high cpu & I/O Slow I/O -> tempdb contention …
  • 46. “Troubleshooting Performance Problems in SQL Server 2008” http://msdn.microsoft.com/en- us/library/dd672789.aspx