简体   繁体   English

在SQL Server Profiler中记录数据传输时间

[英]Logging data transfer time in SQL Server Profiler

I've been using SQL Server profiler quite frequently to check for redundant or badly performing queries. 我一直很频繁地使用SQL Server事件探查器来检查冗余或性能不佳的查询。

But is there an event (among the giant list) that allows you to log the total amount of time it takes to transfer the data from the data base to the application? 但是,是否有一个事件(在巨型列表中)允许您记录将数据从数据库传输到应用程序所需的总时间?

This would be a very good indicator for queries that return way more data than needed in the application. 对于返回比应用程序所需更多数据的查询,这将是一个很好的指示。

Once data leaves SQL Server, it's at the mercy of your hardware (NICs and network latency). 数据离开SQL Server之后,将由您决定(NIC和网络延迟)。

You would typically profile that from the client side of things. 您通常会从客户端的角度进行分析。

Use SQL Profiler to observe the number of reads performed by queries. 使用SQL事件探查器观察查询执行的读取次数。 This is a good indicator. 这是一个很好的指标。 Queries that use 'SELECT *' typically can't use a covering index, so look for Bookmark lookups. 使用'SELECT *'查询通常不能使用覆盖索引,因此请查找“书签”查询。

It sounds to me like you are wanting to identify queries that return large result sets. 在我看来,您想要识别返回大结果集的查询。 Taking this a level deeper then, what you really want to do is to identify which queries are consuming the largest amount of data. 接下来,您真正想做的就是确定哪些查询消耗的数据量最大。 This can be seen in terms of both logical reads and physical reads. 可以从逻辑读取和物理读取两者来看。

In order to view this information in a report you can use the freely available Performance Dashboard Reports or make use of the SQL Server DMV's. 为了在报告中查看此信息,您可以使用免费的性能仪表盘报告或使用SQL Server DMV。

For example, the following queries have been taken from the excellent SQL Server Performance Blog by Glenn Berry: 例如,以下查询来自Glenn Berry的出色SQL Server性能博客

/* Top Cached SPs By Total Logical Reads (SQL 2008). Logical reads relate to memory pressure */
SELECT TOP(25) p.name AS [SP Name], qs.total_logical_reads AS [TotalLogicalReads], 
qs.total_logical_reads/qs.execution_count AS [AvgLogicalReads],qs.execution_count, 
ISNULL(qs.execution_count/DATEDIFF(Second, qs.cached_time, GETDATE()), 0) AS [Calls/Second], 
qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count 
AS [avg_elapsed_time], qs.cached_time
FROM sys.procedures AS p
INNER JOIN sys.dm_exec_procedure_stats AS qs
ON p.[object_id] = qs.[object_id]
WHERE qs.database_id = DB_ID()
ORDER BY qs.total_logical_reads DESC;

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

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