简体   繁体   English

是否有类似于Java / .Net profilers的SQL Server探查器?

[英]Is there a SQL Server profiler similar to Java/.Net profilers?

I love the way I can profile a Java/.Net app to find performance bottlenecks or memory problems. 我喜欢我可以分析Java / .Net应用程序以查找性能瓶颈或内存问题的方式。 For example, it's very easy to find a performance bottleneck looking at the call tree with execution times and invocation counts per method . 例如, 通过执行时间和每个方法的调用计数 ,可以很容易地找到查看调用树的性能瓶颈。 In SQL Server, I have stored procedures that call other stored procedures that depend on views, which is similar to Java/.Net methods calling other methods. 在SQL Server中,我有存储过程,这些过程调用依赖于视图的其他存储过程,这类似于调用其他方法的Java / .Net方法。 So it seems the same kind of profiler would be very helpful here. 所以看起来同样的分析器在这里会非常有用。 However, I looked far and wide and could not find one. 但是,我看起来很远,找不到一个。 Is anyone aware of such tools, either for SQL Server or any other DBMS? 是否有人知道这些工具,无论是SQL Server还是其他任何DBMS?

Update: Thanks fro your replies around SQL Server Profiler, but this tool is very limited. 更新:感谢您对SQL Server Profiler的回复,但此工具非常有限。 Take a look at the screenshot . 看一下截图

Check out SQL Nexus Tool . 查看SQL Nexus工具 This has some good reports on identifying bottlenecks. 这有一些关于识别瓶颈的好报告。 SQL Nexus is a tool that helps you identify the root cause of SQL Server performance issues. SQL Nexus是一个工具,可以帮助您确定SQL Server性能问题的根本原因。 It loads and analyzes performance data collected by SQLDiag and PSSDiag. 它加载并分析SQLDiag和PSSDiag收集的性能数据。 It can dramatically reduce the amount of time you spend manually analyzing data. 它可以大大减少您手动分析数据所花费的时间。

In one of the Inside SQL 2005 books (maybe T-SQL Querying), there was a cool technique in which the author dumps the SQL profiler output to a table or excel file and applies a pivot to get the output in a similar format as your screenshot. 在其中一本Inside SQL 2005书籍(可能是T-SQL查询)中,有一种很酷的技术,其中作者将SQL事件探查器输出转储到表或excel文件,并应用一个数据透视表以获得与您的输出格式类似的输出屏幕截图。

I have not seen any built-in SQL tools which gives you that kind of analysis. 我还没有看到任何内置的SQL工具可以为您提供这种分析。 Another useful post . 另一个有用的帖子

In addition to SQL Server Profiler, as mentioned in a comment from @Galwegian, also check out your execution plan when you run a query. 除了@Galwegian的评论中提到的SQL Server Profiler之外,还可以在运行查询时查看执行计划。

http://www.sql-server-performance.com/tips/query_execution_plan_analysis_p1.aspx http://www.sql-server-performance.com/tips/query_execution_plan_analysis_p1.aspx
http://en.wikipedia.org/wiki/Query_plan http://en.wikipedia.org/wiki/Query_plan

Another whole thread about the SQL Server profiler: 关于SQL Server探查器的另一个完整线程:

Identifying SQL Server Performance Problems 识别SQL Server性能问题

I understand what you are talking about, but typically, database optimization takes place at a finer grained level. 我理解你在说什么,但通常情况下,数据库优化是在更细粒度的水平上进行的。 If the database activity is driven from a client, you should be able to use the existing client profiler to get the total time on each step and then address the low hanging fruit (whether in the database or not). 如果数据库活动是从客户端驱动的,那么您应该能够使用现有的客户端分析器来获取每个步骤的总时间,然后解决低挂果(无论是否在数据库中)。

When you need to profile a particular database step in detail, you can use profiler and a trace. 当您需要详细分析特定数据库步骤时,可以使用分析器和跟踪。

Typically, the database access has a certain granularity which is addressed on an individual basis and database activity is not linear with all kinds of user access going on, whereas a program profiler is typically profiling a linear path of code. 通常,数据库访问具有一定的粒度,该粒度是基于个体来解决的,并且数据库活动与正在进行的所有类型的用户访问不是线性的,而程序分析器通常是对代码的线性路径进行分析。

As mentioned, SQL Server Profiler, which is great for checking what parameters you're program is passing to SQL etc. It won't show you an execution tree though if that's what you need. 如前所述,SQL Server Profiler非常适合检查您正在编程的参数传递给SQL等。但是如果您需要,它将不会显示执行树。 For that, all I can think of is to use Show Plan to see what exactly is executed at run-time. 为此,我能想到的是使用Show Plan来查看在运行时确切执行的内容。 Eg if you're calling an sp that calls a view, Profiler will only show you that the sp was executed and what params were passed in. Also, the Windows Performance Monitor has extensive run-time performance metrics specific to SQL Server. 例如,如果您正在调用调用视图的sp,则Profiler将仅显示sp已执行以及传入了哪些参数。此外,Windows性能监视器具有特定于SQL Server的广泛运行时性能指标。 You can run it on the server, or connect remotely. 您可以在服务器上运行它,也可以远程连接。

要查找性能瓶颈,可以使用数据库引擎优化顾问(位于SQL Server Management Studio的“工具”菜单中。它提供了优化查询的建议,并自动为您优化它们(例如,创建适当的索引等)。

You could use S ql Profiler - which covers the profiling aspect, but I tend to think of it more as a logging tool. 您可以使用S ql Profiler - 它涵盖了性能分析方面,但我更倾向于将其视为日志记录工具。 For diagnosing performance, you should probably just be looking at the query plan . 为了诊断性能,您可能只是在查看查询计划

There's the sql server profiler, but despite it's name, it doesn't do what you want, by the sound of your question. 有sql server profiler,但是尽管它的名字,它根本不是你想要的,你的问题的声音。 It'll show you a detailed view of all the calls going on in the database. 它将向您显示数据库中正在进行的所有调用的详细视图。 It's Better for troubleshooting the app as a whole, not just one sproc at a time 最好对整个应用程序进行故障排除,而不是一次只对一个sproc进行故障排除

Sounds like you need to view the execution plan of your queries/spocs in query analyzer and that will give you something akin to the data you are looking for. 听起来你需要在查询分析器中查看查询/ spocs 的执行计划 ,这将为你提供类似于你正在寻找的数据的东西。

As mentioned by several replies the SQL Profiler will show what you're asking for. 正如几篇回复中所提到的,SQL Profiler将显示您要求的内容。 What you'll have to be sure to do is to turn on the events SP:StmtCompleted, which is in the Stored Procedures group, and if you want the query plans as well turn on Showplan XML Statistics Profile, which is in the Performance group. 您必须要做的是打开事件SP:StmtCompleted,它位于Stored Procedures组中,如果您还想要查询计划,请启用Showplan XML Statistics Profile,它位于Performance组中。 The XML plan last one gives you a graphical description and shows the actual rows processed by each step in the plan. 最后一个XML计划为您提供了图形描述,并显示了计划中每个步骤处理的实际行。

If the profiler is slowing your app down, filter it as much as possible and consider going to a server side trace. 如果分析器正在减慢您的应用程序速度,请尽可能过滤它并考虑转到服务​​器端跟踪。

HTH Andy HTH安迪

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM