MonitoringandOptimizingSQLServerPerformance

上传人:re****.1 文档编号:592473871 上传时间:2024-09-20 格式:PPT 页数:48 大小:661.50KB
返回 下载 相关 举报
MonitoringandOptimizingSQLServerPerformance_第1页
第1页 / 共48页
MonitoringandOptimizingSQLServerPerformance_第2页
第2页 / 共48页
MonitoringandOptimizingSQLServerPerformance_第3页
第3页 / 共48页
MonitoringandOptimizingSQLServerPerformance_第4页
第4页 / 共48页
MonitoringandOptimizingSQLServerPerformance_第5页
第5页 / 共48页
点击查看更多>>
资源描述

《MonitoringandOptimizingSQLServerPerformance》由会员分享,可在线阅读,更多相关《MonitoringandOptimizingSQLServerPerformance(48页珍藏版)》请在金锄头文库上搜索。

1、Monitoring and Optimizing SQL Server 2005 PerformanceAnil DesaiSpeaker InformationAnil DesaiIndependent consultant (Austin, TX)Author of several SQL Server booksInstructor, “Implementing and Managing SQL Server 2005” (Keystone Learning)Info: http:/AnilD or AnilAnilD Agenda and OverviewPerformance Mo

2、nitoring OverviewUsing SQL ProfilerIntegrating with Windows System MonitorGetting Performance InformationDynamic Management Views (DMVs)SQL Server Management Studio ReportsUsing the Database Engine Tuning AdvisorManaging Processes, Locking, and DeadlocksPartitioning and Physical Storage DesignPerfor

3、mance Monitoring ApproachesPerformance optimization process:1.Establish a baseline2.Identify bottlenecks3.Make one change at a time4.Measure performance5.Repeat (if desired)RecommendationsOptimize for real-world workloads Monitor/review performance regularly Focus on specific issuesOverview of Perfo

4、rmance MonitoringSystemWindows System MonitorAlerts (Performance-Based)SQL ServerSQL Profiler / SQL TraceActivity MonitorDynamic Management Views (DMVs)SQL Server Agent AlertsQuery-LevelDatabase Engine Tuning AdvisorQuery Execution Plans Understanding SQL ProfilerPurpose / Features: GUI for managing

5、 SQL TraceMonitor important eventsCapture performance data / resource usageReplaying of workloads / transactionsIdentifying performance bottlenecksCorrelation of data with System MonitorWorkloads for Database Tuning AdvisorExamples:Generate a list of the 100 slowest queriesMonitor all failed logins

6、(Security)SQL Server Profiler ArchitectureSQL Profiler TerminologyTrace DefinitionsEventsColumnsFiltersCreating and Managing SQL TracesSQL Profiler (GUI)System Stored Procedures (Transact-SQL)Trace Templates (Built-In)Standard (Default), SP_CountsTSQL, TSQL_Duration, TSQL_Grouped,TSQL_Replay, TSQL_S

7、PsTuningConfiguring Trace EventsGroupings:Event Categories Event ClassesEventsExamples:TSQLStored ProceduresPerformanceErrors and WarningsSecurity auditingConfiguring Trace ColumnsSpecify the details to be recordedColumns can be ordered and groupedValues can be filteredExamples of Columns:StartTime

8、/ EndTimeTextDataDurationResource Usage (CPU, Reads, Writes)Information: User, Database, App. NamesTrace Output OptionsInteractiveGood for “live” monitoring of small sets of dataTrace Files (*.trc)Can enable file rollover based on size“Server processes trace data” optionTrace tableWill automatically

9、 create the tableCan set maximum number of rowsScheduling of traces (stop time)Creating Profiler TracesLaunching SQL ProfilerConnecting to a database instanceConfiguring output optionsCreate a trace definitionSpecifying events, columns, and filtersOther SQL Profiler OptionsCreating new templatesScri

10、pting trace definitionsExtracting SQL Server EventsTransact-SQL EventsShowPlan EventsDeadlock EventsUsing System Monitor with SQL ProfilerPurpose / Goal:Correlate server performance with database performanceProcess:Define and start a counter logDefine and start a SQL Profiler traceImport Performance

11、 Data in SQL ProfilerRequired Trace propertiesStartTimeEndTimeWindows Performance MonitorCan monitor local or remote computersPerformance Statistics:ObjectsCountersInstancesModes:System MonitorPerformance Logs and AlertsCounter LogsTrace LogsAlertsUsing Dynamic Management Views (DMVs)Purpose:Monitor

12、ing and troubleshootingView server state and performance detailsReturns relational result setsScopes:Server levelDatabase levelDMV ExamplesExamples:Database EngineSys.DM_DB_File_Space_UsageIndexesSys.DM_DB_Index_Operational_StatsSys.DM_DB_Index_Physical_StatsI/O RelatedSys.DM_IO_Pending_IO_RequestsS

13、ys.DM_IO_Virtual_File_StatsCommon Language RuntimeDatabase MirroringTransactionsSQL Server Management Studio ReportsOverviews of SQL Server usageCan export to Excel or PDFServer-Level Report Examples:Server DashboardMemory ConsumptionActivity All Block TransactionsActivity Top SessionsPerformance Ba

14、tch Execution StatisticsPerformance Top Queries by Average CPUObject Execution StatisticsDatabase-Level ReportsExamples:Disk UsageAll TransactionsAll Blocking TransactionsIndex Usage StatisticsTop Transactions by AgeSchema Changes HistoryMonitoring SQL Server LogsWindows Event Logs / Event Viewer Ap

15、plication and System Event LogsSQL Server Management StudioSQL Server LogsCan configure max. # of log filesSQL Server Agent Error logsCan configure logging levels (Errors, Warnings, Information)Using the Log File ViewerCan Export / Load log informationCan search for specific errors/messagesUsing SQL

16、DiagData Collected:System Information (MSINFO)Windows Event LogsSQL Server configurationCommand-Line Utility (SQLDiag.exe)Stores output to filesConfiguration file: SQLDiag.xmlCan run as a service (/R)Can run in continuous modeDatabase Engine Tuning AdvisorCan make performance-related recommendations

17、Replaces the “Index Tuning Wizard”Evaluates Physical Design Structures (PDS)Indexes (clustered, non-clustered)Indexed ViewsPartitionsNumerous analysis optionsOutputGenerates modification scriptsGenerates Reports for later analysisWorkloadsFilesTransact-SQL FilesXML FilesShould represent commonly-use

18、d queriesSQL Profiler Trace Files / TablesUse Tuning built-in trace templateEvents: Transact-SQL BatchRemote Procedure Call (RPC)Columns: Event Class and Text DataDTA OptionsLimit tuning time Tuning OptionsAllowed Physical Design Structures (PDS)Keep all/specific existing objectsMaximum storage spac

19、eOnline or offline recommendationsPartitioningDTA ReportsCan export to XML filesExamples:Workload analysisColumn accessTable accessView-Table RelationsStatement costEvent frequencyIndex Usage (current / recommended)Using the Database Engine Tuning AdvisorProcess:Generate a workload (file or table)Se

20、lect tuning optionsRun the analysisView reportsSave and/or apply recommendationsRunning the DTA:Database Engine Tuning Advisor Application (GUI)Dta.exe command-line utilityUnderstanding ProcessesProcessesInteractive users SQL Server Management StudioApplications (Connection Pooling)SQL ProfilerDatab

21、ase Engine Tuning AdvisorReplicationService BrokerProcess IDs 50 are system-relatedMonitoring ProcessesSQL Server Activity MonitorProcesses (connected users)Locks (by Process / by Object)Filtering optionsAuto-refresh optionSystem Stored Procedures / ViewsSys.DM_Exec_Sessions Sys.DM_Exec_RequestsSys.

22、SysProcessessp_who / sp_who2Managing ProcessesProcess InformationCurrent Process ID: SPIDSession Options: DBCC USEROPTIONSKilling ProcessesKILL ProcessID WITH STATUSONLYViewing Last ActivityDBCC INPUTBUFFER(ProcessID)DBCC OUTPUTBUFFER(ProcessID)Understanding LockingCoordinates multiple accesses to t

23、he same dataEnsures ACID Properties for transactions (Atomic, Consistent, Independent, Durable)Contention can reduce performanceLocking granularity: Row-Level, Page-Level, Table-Level, etc.Lock Modes: Shared, Exclusive, etc.Lock escalationUnderstanding BlockingBlockingWhen transaction(s) must wait f

24、or a lock on a resourceLOCK_TIMEOUT setting (default = wait forever)Locking Models:PessimisticOptimisticTransaction Isolation LevelsBalance of concurrency (performance) vs. consistencyAffects SELECT queriesSET TRANSACTION ISOLATION LEVELTransaction Isolation LevelsREAD UNCOMMITTEDREAD COMMITTED (def

25、ault)REPEATABLE READSERIALIZABLERow-Versioning:ALLOW_SNAPSHOT_ISOLATION READ_COMMITTED_SNAPSHOTMonitoring Locking ActivityActivity MonitorSQL ProfilerLocks Event CategorySystem Monitor: SQL Server Locks ObjectSystem ViewsSys.DM_Tran_LocksSys.DM_Exec_RequestsSystem Stored Proceduressp_LockUnderstandi

26、ng the Deadlock ProcessDeadlocks:Two or more tasks permanently block each other based on resource locksDefault resolution is within 5 secondsDeadlock victim Transaction is rolled-backProcess receives a 1205 errorExample:Process 1 locks the Customers table and requires access to the Orders TableProce

27、ss 2 locks the Orders table and requires access to the Customers TableAvoiding DeadlocksMinimize transaction timesCommit / Rollback transactions as quickly as possiblyAvoid user-related time within a transactionAccess objects in a consistent orderChange the transaction isolation levelUse a lower lev

28、el isolation level, if appropriateUse snapshot-based isolation levelsDeadlock VictimsDeadlock priorities:SET DEADLOCK_PRIORITY (LOW, NORMAL, HIGH, integer)Deadlock resolution:Lower priority is killed firstIf equal priorities, least expensive transaction becomes the victimApplication or user should a

29、ttempt to re-run the transactionMonitoring DeadlocksSQL Server Error LogSQL Profiler Locks Event CategoryLock:Deadlock ChainLock:DeadlockDeadlock GraphEvents Extraction Trace PropertyExport deadlock XML (.xdl) fileViewing Deadlock FilesSQL Server Management Studio (File Open SQL Deadlock Files (*.xd

30、l)Deadlock GraphUnderstanding PartitionsPhysical distribution of dataPartitions can be on the same or different filegroupsPartitioning MethodsHorizontal PartitioningVertical PartitioningExample:Partition 1: Current Sales Data (Current Year)Partition 2: Archived Sales DataBenefits of PartitioningNo s

31、pecial requirements for users or applicationsCan partition tables and indexesFast transfer of data between partitions Supports “Sliding” windowsCan improve query performanceSimplifies management of large tablesIncreases maintenance performance (indexes)Designing PartitionsReasons to implement partit

32、ioningLarge tablesPerformance problemsData usage (read-only historical data)Partial backupsSupported in Enterprise and Developer EditionsCan have up to 1,000 partitionsImplementing PartitionsProcess:Create a partition functionCreate a partition schemeCreate a table using the schemeOther options:Mana

33、ging partitioned dataCreating CHECK constraintsCreating a Partition FunctionDefines sets of data based on ranges within the partitioning columnExamples: Dates, Row IDs, alpha valuesRANGE LEFT (default) / RIGHTComputed columns must be persistedExample:CREATE PARTITION FUNCTION fn_part1 (int) AS RANGE

34、 LEFT FOR VALUES (1000, 2000, 3000)$PARTITION Function shows on which partition data would resideCreating a Partition SchemeDefines storage options for each partitionBased on a single partition functionCan specify files or filegroups for storageA filegroup can be used for multiple partitionsExample:

35、CREATE PARTITION SCHEME Partition1AS PARTITION PartitionFunctionTO (FileGroup1, FileGroup2, FileGroup3)Creating Partitioned TablesSpecify the partition scheme when creating a tableCREATE TABLE ON PartitionSchemeData storage will be based on the partition schemeCreating Partitioned Indexes“Aligned” p

36、artitioningIndex partitions are based on table partitionsManaged automatically by SQL ServerOptimizes switching performanceManual partition managementCan use CREATE INDEX ON clausePartition column is automatically included in clustered and non-clustered indexesManaging Partitioned DataPhysical locat

37、ion of data may not be moved (only pointers are updated)CHECK constraints can be used to manage data“Sliding Windows”Partition functions can be modifiedSplitting: Adding a new partitionMerging: Combining two partitionsPartition switchingALTER TABLE SWITCHMoves data between partitionsWorking with Par

38、titioned DataSQL Server Management Studio Database Reports Disk Space Used by Partitions ObjectNameSystem Views:Sys.Tables / Sys.IndexesSys.PartitionsSys.Partition_SchemesSys.Partition_ParametersSys.Partition_Range_ValuesFor More InformationResources from Anil DesaiWeb Site (http:/AnilD)E-Mail: AnilAnilD Keystone Learning Course: “Microsoft SQL Server 2005: Implementation and Maintenance (Exam 70-431)”The Rational Guide to Managing Microsoft Virtual Server 2005The Rational Guide to Scripting Microsoft Virtual Server 2005

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 医学/心理学 > 基础医学

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号