Key Concepts About Performance Factors Affecting SQL Performance SQL Performance Tuning...
-
Upload
virginia-dixon -
Category
Documents
-
view
220 -
download
4
Transcript of Key Concepts About Performance Factors Affecting SQL Performance SQL Performance Tuning...
![Page 1: Key Concepts About Performance Factors Affecting SQL Performance SQL Performance Tuning Methodologies SQL Performance Tuning Tools 1.](https://reader030.fdocuments.us/reader030/viewer/2022032803/56649e395503460f94b2ab90/html5/thumbnails/1.jpg)
1
Agenda
Key Concepts About PerformanceFactors Affecting SQL PerformanceSQL Performance Tuning MethodologiesSQL Performance Tuning Tools
![Page 2: Key Concepts About Performance Factors Affecting SQL Performance SQL Performance Tuning Methodologies SQL Performance Tuning Tools 1.](https://reader030.fdocuments.us/reader030/viewer/2022032803/56649e395503460f94b2ab90/html5/thumbnails/2.jpg)
2
Key Concepts About Performance
What is performance issue?CPU utilization high, memory usage high, disk latency high?Query response is slow?Query timeout/failure?
Response TimeThroughputBaselineBottleneck
![Page 3: Key Concepts About Performance Factors Affecting SQL Performance SQL Performance Tuning Methodologies SQL Performance Tuning Tools 1.](https://reader030.fdocuments.us/reader030/viewer/2022032803/56649e395503460f94b2ab90/html5/thumbnails/3.jpg)
3
Factors Affecting SQL Performance
Application Designdata caching, data archivingtransactional/reporting access isolation, read/write access isolationtransaction management (concurrency control)
Database Design missing indexes, excessive indexesinappropriate column types, over-normalization, table partitioning
Query Design poor queries (OR/LIKE/EXISTS operators, indexed column conversion)inappropriate use of views/triggers/cursors
SQL Server and OSimproperly configured (PAE/AWE, max server memory, MAXDOP)Improperly maintained (inaccurate statistics, index fragmentation)
Hardwareinsufficient resources (CPU, Memory, Disk, etc.)
![Page 4: Key Concepts About Performance Factors Affecting SQL Performance SQL Performance Tuning Methodologies SQL Performance Tuning Tools 1.](https://reader030.fdocuments.us/reader030/viewer/2022032803/56649e395503460f94b2ab90/html5/thumbnails/4.jpg)
4
SQL Performance Tuning Methodologies
Is there resource bottleneck?CPU, Memory, Disk, etc.
What is happening in SQL Server?What has happened in SQL Server?Tuning slow queries
High CPU/IO queriesLow CPU/IO, high duration queries
![Page 5: Key Concepts About Performance Factors Affecting SQL Performance SQL Performance Tuning Methodologies SQL Performance Tuning Tools 1.](https://reader030.fdocuments.us/reader030/viewer/2022032803/56649e395503460f94b2ab90/html5/thumbnails/5.jpg)
5
Is there resource bottleneck?
Windows Performance CountersCPU
Processor\%Processor TimeProcess(sqlservr)\% Processor Time
MemoryMemory\Available MbytesSQLServer:Buffer Manager\Lazy writes/secSQLServer:Buffer Manager\Page life expectancySQLServer:Buffer Manager\Page reads/sec
DiskPhysicalDisk\Avg. Disk sec/ReadPhysicalDisk\Avg. Disk sec/WritePhysicalDisk\% Idle Time
SQL Server Resource Wait StatisticsSQLServer:Wait Statistics
SQL Server system catalogssys.dm_os_wait_statssys.dm_os_waiting_tasks
![Page 6: Key Concepts About Performance Factors Affecting SQL Performance SQL Performance Tuning Methodologies SQL Performance Tuning Tools 1.](https://reader030.fdocuments.us/reader030/viewer/2022032803/56649e395503460f94b2ab90/html5/thumbnails/6.jpg)
6
Analyzing what is happening
Point-in-time analysisWho is activeIs it running or waiting?What is it waiting for?
Analyzing active sessionsRunning, Runnable or Suspended
Using Management Studio Activity MonitorGraphical Reports
Using system catalogs sys.dm_exec_requestssys.dm_exec_sessionssys.dm_os_waiting_taskssys.sysprocesses, sp_who, sp_who2
![Page 7: Key Concepts About Performance Factors Affecting SQL Performance SQL Performance Tuning Methodologies SQL Performance Tuning Tools 1.](https://reader030.fdocuments.us/reader030/viewer/2022032803/56649e395503460f94b2ab90/html5/thumbnails/7.jpg)
7
Analyzing what has happened
Cumulative analysisWhose duration has been long?Who has consumed the most resources?What has it been waiting for?
Analyzing top queries and top resource waitsHigh duration, CPU or IO
Using Management Studio Graphical Reports
Using system catalogs sys.dm_exec_query_statssys.dm_os_wait_statssys.dm_db_index_usage_stats
Using SQL Server Tracing
![Page 8: Key Concepts About Performance Factors Affecting SQL Performance SQL Performance Tuning Methodologies SQL Performance Tuning Tools 1.](https://reader030.fdocuments.us/reader030/viewer/2022032803/56649e395503460f94b2ab90/html5/thumbnails/8.jpg)
Tuning expensive queries
High CPU/IO queriesTuning the query itself: analyzing the execution planPossible solutions:
Optimizing index designUpdating index statisticsOptimizing T-SQL queriesOptimizing application logic design
High duration queriesIdentifying the waited resource
Most popular causes: blocking issue, Disk IO bottleneck, latch contention.http://technet.microsoft.com/library/Cc966413
Possible solutions:Optimizing transaction/application logic designOptimizing Disk IO systems
![Page 9: Key Concepts About Performance Factors Affecting SQL Performance SQL Performance Tuning Methodologies SQL Performance Tuning Tools 1.](https://reader030.fdocuments.us/reader030/viewer/2022032803/56649e395503460f94b2ab90/html5/thumbnails/9.jpg)
9
SQL Performance Tuning Tools
SQL Server Management StudioActivity MonitorGraphical Reports
SQL Server Performance Dashboard Reports http://www.microsoft.com/en-us/download/details.aspx?id=29063
Query Execution PlanSystem Catalogs
TracingPssdiag/SqldiagSQLNexus
![Page 10: Key Concepts About Performance Factors Affecting SQL Performance SQL Performance Tuning Methodologies SQL Performance Tuning Tools 1.](https://reader030.fdocuments.us/reader030/viewer/2022032803/56649e395503460f94b2ab90/html5/thumbnails/10.jpg)
10
Tracing
Data collection for SQL Server internal events Some of the events are performance relatedTracing introduces performance overhead
Two methods:SQL Profiler: GUI tool, more overheadServer Side: Using system stored procedures to define and execute server-side trace, less overhead
sp_trace_createsp_trace_setstatussys.traces
Tracing template
![Page 11: Key Concepts About Performance Factors Affecting SQL Performance SQL Performance Tuning Methodologies SQL Performance Tuning Tools 1.](https://reader030.fdocuments.us/reader030/viewer/2022032803/56649e395503460f94b2ab90/html5/thumbnails/11.jpg)
11
Tracing - Events
TSQLSQL:BatchStarting, SQL:BatchCompletedSQL:StmtStarting, SQL:StmtCompleted
Stored ProceduresRPC:Starting, RPC:CompletedSP:Starting, SP:CompletedSP:StmtStarting, SP:StmtCompleted
PerformanceShowplan XMLShowplan XML Statistics Profile
Error and WarningsBlocked process report
LocksDeadlock graph
![Page 12: Key Concepts About Performance Factors Affecting SQL Performance SQL Performance Tuning Methodologies SQL Performance Tuning Tools 1.](https://reader030.fdocuments.us/reader030/viewer/2022032803/56649e395503460f94b2ab90/html5/thumbnails/12.jpg)
Pssdiag/Sqldiag
Collecting all the useful data togetherWindows performance LogsWindows event LogsSQL Server configuration informationSQL Server traceActive sessionsBlocking informationResoure wait statistics
Free download (Pssdiag/Sqldiag Manager)http://diagmanager.codeplex.com
![Page 13: Key Concepts About Performance Factors Affecting SQL Performance SQL Performance Tuning Methodologies SQL Performance Tuning Tools 1.](https://reader030.fdocuments.us/reader030/viewer/2022032803/56649e395503460f94b2ab90/html5/thumbnails/13.jpg)
SQLNexus
Loads and analyzes performance data collected by Pssdiag/Sqldiag
CPU utilizationResource wait statisticsBlockingsTop queries
Free downloadhttp://sqlnexus.codeplex.com
![Page 14: Key Concepts About Performance Factors Affecting SQL Performance SQL Performance Tuning Methodologies SQL Performance Tuning Tools 1.](https://reader030.fdocuments.us/reader030/viewer/2022032803/56649e395503460f94b2ab90/html5/thumbnails/14.jpg)
http://social.technet.microsoft.com/wiki/contents/articles/5957.sql-server-performance-survival-guide.aspx
SQL Server Performance Survival Guide