亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

SQL Server 2008性能故障排查(一)——概論

系統 1969 0
原文: SQL Server 2008性能故障排查(一)——概論


備注:本人花了大量下班時間翻譯,絕無抄襲,允許轉載,但請注明出處。由于篇幅長,無法一篇博文全部說完,同時也沒那么快全部翻譯完,所以按章節發布。由于本人水平有限,翻譯結果肯定存在問題,為了不造成誤導,在每篇結尾處都附上原文,供大家參考,也希望能指出我的問題,以便改進。謝謝。

另外,本文寫給稍微有經驗的數據庫開發人員或者DBA看,初學者可能會看不懂。在此請見諒

作者 :Sunil Agarwal, Boris Baryshnikov, KeithElmore, Juergen Thomas, Kun Cheng, Burzin Patel

技術評審 :Jerome Halmans, Fabricio Voznika,George Reynya

發布于 :2009年3月

適用于 :SQL Server 2008


概要:

有時候對一個工作負載進行劣質的數據庫設計或者不正確的系統配置會引起SQLServer運行緩慢。DBA需要主動地防止或者最小化問題,并且當問題發生后,診斷問題的起因并作出正確的響應。本文提供逐步指引,使用公開可用的工具如 SQLServer Profiler、性能監視器、DMV、SQLServer擴充事件 數據收集器 來診斷和排查常見性能問題。

?

版權:本部分略去,請尊重他人勞動成果即可


簡介:

SQLServer偶爾運行緩慢是不常見的現象。一般原因可以歸結為:對一個工作負載進行劣質的數據庫設計或者不正確的系統配置。作為一個DBA,需要主動避免或者最小化問題。當問題發生時,需要去診斷起因和作出正確的對策。本白皮書提供了各種工具如SQLServer Profiler、性能監視器、DMV、SQLServer擴充事件和數據收集器來診斷和排查常見性能問題。本白皮書把問題范圍限制在一些客戶經常反映的地方,因為分析所有可能的問題是不現實的。

目標:

本文的主要目的是提供常規方法,主要是一些公開的、可用的工具用于診斷和故障排查。SQLServer 2008在支持性上有了重大的提升。添加了一些新動態管理視圖(DMV):如sys.dm_os_memory_brokers,sys.dm_os_memory_nodes,sys.dm_exec_procedure_stats。已有(2005出現)的DMV比如:sys.dm_os_sys_info,sys.dm_exec_requests和sys.dm_exec_requests也添加了很多新的信息。你可以DMV和使用現有的工具如SQL Server Profiler、性能監視器來收集性能相關數據用于分析。
第二個目的是介紹新的故障排查工具和2008特性,包括擴充事件(Extended Events)和數據收集器(data collector)


方法論:

SQLServer運行緩慢的原因可能有很多種,本文中根據下面3個主要癥狀來開始問題診斷:

  • ?資源瓶頸(Resource Bottlenecks):CPU、內存和I/O瓶頸都將在本文中提及。我們不考慮網絡問題。在每個資源瓶頸中,我們會描述如何標識出問題然后迭代地檢查可能的原因。比如,一個內存瓶頸會引起過多的頁面切換從而影響性能。
  • TempDB瓶頸:因為在每個SQLServer實例中,只有一個tempdb可被個個數據庫使用,所以它可能成為性能問題和硬盤空間瓶頸。一個應用可能因為過多的DDL或者DML操作,并且耗用過多資源,會使得tempdb超負荷。這能引起非相關的、運行在同一服務器上的應用程序變得緩慢甚至運行失敗。
  • 一個運行緩慢的用戶查詢:一個已存在的查詢可能會影響性能,或者一個新的查詢會耗費比想象中更多的資源。一般由以下原因引起:
? 1、一個現有查詢的統計信息的改變會使得優化器選擇一個性能低下的執行計劃。
? 2、丟失索引將導致強制表掃描和減慢查詢速度。
? 3、應用程序也會因為阻塞從而影響性能,即使資源利用情況很正常。
? 4、一些不好的應用程序、不合理的架構設計或者使用了不合適的事務隔離級別,都會導致過多的阻塞。
上面的這些原因不應該分開來分析,低效的執行計劃會加重系統資源的使用從而引起工作負載的性能總體下降。所以,如果一個大表丟失了一個有效的索引,或者查詢優化器不選擇使用這個索引,那么查詢將非常慢。這些情況也同時會對I/O子系統的讀操作帶來很大壓力,因為不得不去讀取一些本來沒必要或者本來已經緩存在內存中的頁。類似于一個經常運行的程序過度的編譯將為CPU帶來壓力。
  • ?在SQL Server 2008中新的性能工具:SQLServer2008提供了新的工具和特性去協助你監控和故障排查。我們主要討論的是:擴充事件和數據收集器

資源瓶頸(Resource Bottlenecks):

在接下來的部分,將討論CPU、內存和I/O子系統資源,并且討論在什么情況下它們會成為瓶頸(網絡部分不在本文討論范圍內)。對于每個資源瓶頸,我們將討論如何識別問他你,然后迭代地檢查可能的原因。比如內存瓶頸將導致切換頁面過多,從而影響性能。
在你能判斷性能瓶頸之前,你必須知道在正常情況下資源是如何被利用的。你能使用本文描述的方法去收集性能基線。即在沒有性能問題之前的性能數據。
你可能發現資源使用正常,但是SQLServer在目前的配置下不能支持相應的負載。為了解決這個問題,你可能不得不增加更多更強大的資源,如內存、加大你目前I/O或者網絡的帶寬。但是,在你執行之前,你有必要先了解資源瓶頸的常規起因。一些解決方案,如重新配置,而不一定非要增加資源。


解決資源瓶頸的工具:


下列工具中的一個或多個能在解決部分性能問題時使用到:
? 性能監視器(Performance Monitor):在部分Windows 操作系統中提供,詳細的了解請查閱Windows文檔。
? SQLServer Profiler:在SQLServer的性能工具組中可以找到,可以查看聯機叢書了解。
? DBCC命令:可以查看附錄A和聯機叢書了解。
? DMVs:詳細可查看聯機叢書。
? 擴充事件(Extended Events):可以查看稍后提到的Extended Events部分和聯機叢書。
? 數據收集器和管理數據倉庫(Data collector and the management data warehouse(MDW)):可以查看稍后提及的Data collector and MDW部分及聯機叢書。

下一節:CPU瓶頸


原文:

Troubleshooting Performance Problems in SQL Server 2008
SQL Server Technical Article

Writers: Sunil Agarwal, Boris Baryshnikov, Keith Elmore, Juergen Thomas, Kun Cheng, Burzin Patel
Technical Reviewers: Jerome Halmans, Fabricio Voznika, George Reynya

Published: March 2009
Applies to: SQL Server 2008

Summary: Sometimes a poorly designed database or a system that is improperly configured for the workload can cause the slowdowns in SQL Server. Administrators need to proactively prevent or minimize problems and, when they occur, diagnose the cause and take corrective action. This paper provides step-by-step guidelines for diagnosing and troubleshooting common performance problems by using publicly available tools such as SQL Server Profiler, Performance Monitor, dynamic management views, and SQL Server Extended Events (Extended Events) and the data collector, which are new in SQL Server 2008.


Copyright

The information contained in this document represents the current view of Microsoft Corporation on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication.

This white paper is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED, OR STATUTORY, AS TO THE INFORMATION IN THIS DOCUMENT.

Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in, or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation.

Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property.

Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address, logo, person, place, or event is intended or should be inferred.


? 2009 Microsoft Corporation. All rights reserved.


Microsoft, MSDN, SQL Server, Win32, Windows, Windows Server, and Windows Vista are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.


All other trademarks are property of their respective owners.




Table of Contents
Introduction 1
Goals 1
Methodology 1
Resource Bottlenecks 2
Tools for Resolving Resource Bottlenecks 2
CPU Bottlenecks 3
Excessive Query Compilation and Optimization 4
Detection 5
Resolution 7
Unnecessary Recompilation 9
Detection 10
Resolution 13
Inefficient Query Plan 14
Detection 15
Resolution 15
Intraquery Parallelism 16
Detection 18
Resolution 21
Poor Cursor Usage 21
Detection 22
Resolution 23
Memory Bottlenecks 23
Background 23
Virtual Address Space and Physical Memory 23
AWE, Locked Pages, and SQL Server 23
Memory Pressures 25
Detecting Memory Pressures 26
Tools for Memory Diagnostics 26
New DMVs in SQL Server 2008 27
Resource Governor in SQL Server 2008 27
External Physical Memory Pressure 28
External Virtual Memory Pressure 30
Internal Physical Memory Pressure 30
Caches and Memory Pressure 36
Ring Buffers 37
Internal Virtual Memory Pressure 43
General Troubleshooting Steps in Case of Memory Errors 44
Memory Errors 44
I/O Bottlenecks 48
Resolution 52
tempdb 56
Monitoring tempdb Space 58
Troubleshooting Space Issues 59
User Objects 59
Version Store 60
Internal Objects 62
Excessive DDL and Allocation Operations 65
Resolution 66
Slow-Running Queries 66
Blocking 67
Locking Granularity and Lock Escalation 69
Identifying Long Blocks 71
Blocking per Object with sys.dm_db_index_operational_stats 74
Overall Performance Effect of Blocking Using Waits 75
Monitoring Index Usage 78
Extended Events 80
Data Collector and the MDW 88
Appendix A: DBCC MEMORYSTATUS Description 95
Appendix B: MDW Data Collection 96



Introduction
It’s not uncommon to experience the occasional slowdown of a database running the Microsoft? SQL Server? database software. The reasons can range from a poorly designed database to a system that is improperly configured for the workload. As an administrator, you want to proactively prevent or minimize problems; if they occur, you want to diagnose the cause and take corrective actions to fix the problem whenever possible. This white paper provides step-by-step guidelines for diagnosing and troubleshooting common performance problems by using publicly available tools such as SQL Server Profiler; System Monitor (in the Windows Server? 2003 operating system) or Performance Monitor (in the Windows Vista? operating system and Windows Server 2008), also known as Perfmon; dynamic management views (sometimes referred to as DMVs); and SQL Server Extended Events (Extended Events) and the data collector, which are new in SQL Server 2008. We have limited the scope of this white paper to the problems commonly seen by Microsoft Customer Service and Support, because an exhaustive analysis of all possible problems is not feasible.
Goals
The primary goal of this paper is to provide a general methodology for diagnosing and troubleshooting SQL Server performance problems in common customer scenarios by using publicly available tools.
SQL Server 2008 has made great strides in supportability. New dynamic management views (DMVs) have been added, like sys.dm_os_memory_brokers, sys.dm_os_memory_nodes, and sys.dm_exec_procedure_stats. Existing DMVs such as sys._dm_os_sys_info, sys.dm_exec_requests, and sys.dm_exec_requests have been enriched with additional information. You can use DMVs and existing tools, like SQL Server Profiler and Performance Monitor, to collect performance related data for analysis.
The secondary goal of this paper is to introduce new troubleshooting tools and features in SQL Server 2008, including Extended Events and the data collector.
Methodology
There can be many reasons for a slowdown in SQL Server. We use the following three key symptoms to start diagnosing problems:
? Resource bottlenecks: CPU, memory, and I/O bottlenecks are covered in this paper. We do not consider network issues. For each resource bottleneck, we describe how to identify the problem and then iterate through the possible causes. For example, a memory bottleneck can lead to excessive paging that ultimately impacts performance.
? tempdb bottlenecks: Because there is only one tempdb for each SQL Server instance, it can be a performance and a disk space bottleneck. An application can overload tempdb through excessive DDL or DML operations and by taking too much space. This can cause unrelated applications running on the server to slow down or fail.
? A slow-running user query: The performance of an existing query might regress, or a new query might appear to be taking longer than expected. There can be many reasons for this. For example:
o Changes in statistical information can lead to a poor query plan for an existing query.
o Missing indexes can force table scans and slow down the query.
o An application can slow down due to blocking even if resource utilization is normal.
o Excessive blocking can be due to poor application or schema design or the choice of an improper isolation level for the transaction.
The causes of these symptoms are not necessarily independent of each other. The poor choice of a query plan can tax system resources and cause an overall slowdown of the workload. So, if a large table is missing a useful index, or if the query optimizer decides not to use it, the query can slow down; these conditions also put heavy pressure on the I/O subsystem to read the unnecessary data pages and on the memory (buffer pool) to store these pages in the cache. Similarly, excessive recompilation of a frequently-run query can put pressure on the CPU.
New Performance Tools in SQL Server 2008
SQL Server 2008 introduced new features and tools that you can use to monitor and troubleshoot performance problems. We’ll discuss two features: Extended Events and the data collector.
Resource Bottlenecks
The next sections of this paper discuss CPU, memory, and I/O subsystem resources and how these can become bottlenecks. (Network issues are outside of the scope of this paper.) For each resource bottleneck, we describe how to identify the problem and then iterate through the possible causes. For example, a memory bottleneck can lead to excessive paging, which can ultimately impact performance.
Before you can determine whether you have a resource bottleneck, you need to know how resources are used under normal circumstances. You can use the methods outlined in this paper to collect baseline information about the use of the resource (at a time when you are not having performance problems).
You might find that the problem is a resource that is running near capacity and that SQL Server cannot support the workload in its current configuration. To address this issue, you may need to add more processing power or memory, or you may need to increase the bandwidth of your I/O or network channel. However, before you take that step, it is useful to understand some common causes of resource bottlenecks. Some solutions, such as reconfiguration, do not require the addition of more resources.
Tools for Resolving Resource Bottlenecks
One or more of the following tools can be used to resolve a particular resource bottleneck:
? Performance Monitor: This tool is available as part of the Windows? operating system. For more information, see your Windows documentation.
? SQL Server Profiler: See SQL Server Profiler in the Performance Tools group in the SQL Server 2008 program group. For more information, see SQL Server 2008 Books Online.
? DBCC commands: For more information, see SQL Server 2008 Books Online and Appendix A.
? DMVs: For more information, see SQL Server 2008 Books Online.
? Extended Events: For more information, see Extended Events later in this paper and SQL Server 2008 Books Online.
? Data collector and the management data warehouse (MDW): For more information, see Data Collector and the MDW later in this paper and SQL Server 2008 Books Online.

SQL Server 2008性能故障排查(一)——概論


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 夜夜操天天爽 | 久久久久久青草大香综合精品 | 91国视频在线观看 | 夜夜操夜夜操 | 在线播放a 1 | 久久性生活视频 | 精品久久久久久中文字幕一区 | 精品1区2区3区 | 国产欧美高清 | 欧美国产亚洲一区 | 亚洲原创区 | 国产亚洲亚洲精品777 | 成人亚洲欧美综合 | 视频三区精品中文字幕 | 欧美日本三级 | 亚洲成人免费在线视频 | 久久精品男人的天堂 | 日本一级黄色录像 | 久草久草久草 | 97免费视频在线观看 | 曰曰鲁夜夜免费播放视频 | 99久久综合狠狠综合久久一区 | 欧美激情亚洲激情 | 日日摸日日碰夜夜爽久久 | 色婷婷综合久久久中文字幕 | 日日搞夜夜操 | www亚洲欲色成人久久精品 | www.四虎影视 | 黄色影院在线观看视频 | 国产色吧 | 久久久国产高清 | 国产精品四虎在线观看免费 | 成人手机看片 | 成人三级做爰在线观看男女 | 欧美视频 亚洲视频 | 国产精品一区二区国产 | 久久看免费视频 | 精品国产中文字幕 | 97高清国语自产拍 | 最新国产一区二区精品久久 | 欧美 日韩 中文 |