惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
I
InfoQ
L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
Y
Y Combinator Blog
博客园_首页
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
A
About on SuperTechFans
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
T
The Blog of Author Tim Ferriss
C
Check Point Blog
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Engineering at Meta
Engineering at Meta
B
Blog
爱范儿
爱范儿
Stack Overflow Blog
Stack Overflow Blog
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学
F
Fortinet All Blogs
月光博客
月光博客
GbyAI
GbyAI

博客园 - Steven.zhou

Setting Up Database Mirroring Using Certificates get the server's infomation sql 2005数据库加密实战 Raid(0,1,5,10,01) SQL Server 2005高可用性之镜像功能(http://tech.it168.com/db/s/2007-04-24/200704240837593.shtml) SQL Server 2005高可用性之复制(http://tech.it168.com/db/s/2007-05-15/200705150909375.shtml) SQL Server 2005高可用性之日志传送(http://tech.it168.com/db/s/2007-06-29/200706291229796_2.shtml) SQL Server 2005性能测试实践(读书笔记翻译http://www.testage.net/TestTech/PT/200702/1510.htm) 如何缩小SQL Server数据库日志文件 SQL Server一个特殊查询(http://searchdatabase.techtarget.com.cn/tips/206/2295706.shtml) sql server 2005几个好用易忘的功能 在SSIS中使用自定义的DLL文件 查看数据表的大小 Use Table-Valued Functions as Arrays in SQL Serve 在sql server 中如何移动tempdb到新的位置 动态sql语句返回值 得到所有的触发器(含DDL触发器) 得到数据库中所有用户表的字段、数据类型 在sql2005 中Execute的增强
Troubleshooting the Performance of a SQL Server Solution(...
Steven.zhou · 2008-03-10 · via 博客园 - Steven.zhou

调试sql server 的性能问题是一个非常耗时的过程,两个基本方法:
1。proactive approach :预先估计可能出现的问题。
2。reactive 根据用户体验来解决问题。
影响 sql server2005性能的几个要素:
1。硬件
2。网络
3。SqlServer database engine(配置参数
4.sql server components(SSIS SSAS...)
5.database
6.client application
可以归结为三大问题:
Physical server
SQL Server instance
Database
常用工具:
Task Manager  
This displays information about programs and processes running on the server (or desktop computer). You can use it to get an immediate overview of your server’s performance.
System Monitor  
System Monitor (perfmon.exe) is used to track resource usage on Windows operating systems through a set of installed performance object counters.
Performance Logs and Alerts  
The Performance Logs and Alerts tool allows you to collect performance data automatically from local or remote computers.
Network Monitor Agent  
This detects network problems and identifies network traffic patterns.

SQL Server ProfilerSQL Server Profiler is a graphical tool for using traces. A trace captures event data such as Transact-SQL (T-SQL) statements, the start of a stored procedure executing, a lock being acquired or released on a database object, or security permission checks against objects. You can save the captured data in a file or a table for later analysis. You can also use SQL Server Profiler for monitoring Analysis Services. Another advantage of SQL Server Profiler in SQL Server 2005 is the option to correlate a trace with Windows performance log data.

In this exercise, you will create a deadlock and see it reflected in the SQLServer:Lock : Number of Deadlocks/sec counter. First you will set up the performance log and start a trace; after that you will run some simple T-SQL statements to create a deadlock. SQL Server Profiler can be of great help in detecting the cause of a deadlock. However, for this demonstration, you will use it just to record the T-SQL statements that will generate the deadlock.

1.      Use the Windows Start menu, and choose All Programs Administrative Tools Performance.

2.      Expand Performance Logs and Alerts (in the Windows Performance tool), right-click Counter Logs, and click New Log Settings.

3.      Type Deadlock Log as the name for the counter log, and click OK.

4.      On the General tab, click Add Counters.

5.      In the Performance Object box, select SQLServer:Locks.

      6.Add the Number of Deadlocks/sec counter, and leave _Total selected in the list of instances.
 

7.      Click Close.

8.      Enter 1 as the value for the Interval box under Sample Data Every.

9.Click the Log Files tab, and choose Text File (Comma Delimited) from the Log File Type list (so you can share the log file among different versions of Windows or view the log files later with Microsoft Excel).
 

10.      On the Schedule tab, specify Manually for both the Start Log and Stop Log options.

11. Click OK to create the performance log.

12. Click the Counter Logs node, right-click Deadlock Log, and select Start from the context menu. Leave the System Monitor console open.

13。      From the Windows Start menu, choose All Programs Microsoft SQL Server 2005, and click SQL Server Management Studio. For this exercise, leave SQL Server Management Studio open.

14. Connect to your SQL Server, and then from the Tools menu click SQL Server Profiler.

15. In the File menu (of SQL Server Profiler), select New Trace, and connect to your SQL Server.

16. On the General Tab, enter Correlation Trace as the trace name, select the TSQL_Replay template, and check the Save to File box to specify the trace file location and filename. (We used C:"Correlation Trace.trc.) Click Run.


 

17. Switch back to SQL Server Management Studio.Open a new query window, and run the following query:

       USE tempdb ;
       GO
       CREATE TABLE Employee (
       EmployeeID INT,
     EmployeeName VARCHAR(64)
      )
       GO
    CREATE TABLE Orders (
         OrderID INT,
  Amount INT
    )
       GO
     INSERT INTO Employee VALUES (69, 'Angelina Jolie')
      GO
       INSERT INTO Orders VALUES (1000, 200)
GO

19. Type the following statements in the query window, but do not run the query yet:

       USE tempdb ;
      GO
       BEGIN TRAN
     UPDATE Employee
     SET EmployeeName = 'Lara Croft'
   WHERE EmployeeID = 69
   WAITFOR DELAY '00:00:10'
     UPDATE Orders
       SET Amount = 300
WHERE OrderID = 1000

20. Open a new query window, and type the following statements:

     USE tempdb ;
      GO
      BEGIN TRAN
      UPDATE Orders
   SET Amount = 350
    WHERE OrderID = 1000
      WAITFOR DELAY '00:00:10'
       UPDATE Employee
     SET EmployeeName = 'Aeon Flux'
WHERE EmployeeID = 69

21. Run the query, and then switch to the first query to run it. It should create a deadlock. In one of the query windows you will get an error message “Msg 1205, Level 13, State 45, Line 6 Transaction (Process ID 52) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

22. Switch to System Monitor, and stop the Deadlock log. (Click the Counter Logs node, right-click Deadlock Log, and select Stop from the context menu.)

23. Switch to SQL Server Profiler, stop the trace, and then close it.

24. From the File menu of SQL Server Profiler, select Open, and then click Trace File. Open the trace file you just created (C:"Correlation Trace.trc).

25. From the File menu, select Import Performance Data, and select the log file recorded previously (the default path and name are C:"PerfLogs"Deadlock log_000001.csv).

26. In the Performance Counters Limit Dialog window, check the instance name of your server.

27. You can play with the pointer both from the trace and from the Performance Data window to get a feel for the tool. You can go directly to the maximum value of the counter (the value 1 in this case) by right-clicking the counter (you have just one counter) and selecting Go to Max Value.