C# 什么是 SQL Server Profiler 中的“审核注销”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2132539/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 23:44:56  来源:igfitidea点击:

What is "Audit Logout" in SQL Server Profiler?

c#linqsql-server-2005linq-to-sqlsql-server-profiler

提问by Shaul Behr

I'm running a data import (using C#/Linq), and naturally I'm trying to optimize my queries as much as possible. To this end I'm running a trace on the DB using SQL Server Profiler, with my trace filtered by my SQL login name (it's a name that can uniquely be attributed to my data import process).

我正在运行数据导入(使用 C#/Linq),自然而然我正在尝试尽可能地优化我的查询。为此,我使用 SQL Server Profiler 在数据库上运行跟踪,我的跟踪由我的 SQL 登录名过滤(这是一个可以唯一归因于我的数据导入过程的名称)。

Strangely enough, most of my SQL statements are really quick :) - very few queries even break over the 1ms mark. But spaced in between all my queries are several rows where the EventClass is "Audit Login" or "Audit Logout" - and the duration of an "Audit Logout" can be up to a minute!

奇怪的是,我的大部分 SQL 语句都非常快 :) - 很少有查询甚至超过 1ms 标记。但是在我所有的查询之间有几行,其中 EventClass 是“审计登录”或“审计注销”——并且“审计注销”的持续时间可能长达一分钟!

Has this got something to do with the fact that I'm using transactions in my import? If so, is there any way to find which are the big-hitting queries so I can clean those up?

这与我在导入中使用事务有关吗?如果是这样,有什么方法可以找到哪些是热门查询,以便我可以清理它们?

采纳答案by Thies

If I remember correct, the duration of an Audit Logout is the amount of time the connection was open. E.g. nothing to do with speed of the command - just the amount of time the login was 'logged in'.

如果我没记错的话,审核注销的持续时间是连接打开的时间。例如,与命令的速度无关 - 只是登录“登录”的时间。

回答by Ruben Bartelink

Login/Logout events are related to the setting up / tearing down. IIRC the time is the 'was logged in for time' as opposed to a processing duration as with other log events.

登录/注销事件与设置/拆除有关。IIRC 时间是“登录时间”,而不是与其他日志事件一样的处理持续时间。

In general, one hides these events unless you suspect there's an issue with connection pool management etc.

通常,除非您怀疑连接池管理等存在问题,否则会隐藏这些事件。

The raw times for the batches should be sufficient to diagnose the time the actual activity is taking including the impact of any transactions etc.

批次的原始时间应该足以诊断实际活动所花费的时间,包括任何事务的影响等。

回答by Rory

Also worth noting as in this answerthat Audit Login/Logout may just mean the connection is being reused from / returned to the connection pool.

同样值得注意的是,在这个答案中,审核登录/注销可能只是意味着连接正在从连接池中重用/返回到连接池。

回答by Michele Caggiano

The Audit Logout event class indicates that a user has logged out of (logged off) Microsoft SQL Server. Events in this class are fired by new connections or by connections that are reused from a connection pool.

审核注销事件类指示用户已注销(注销)Microsoft SQL Server。此类中的事件由新连接或从连接池中重用的连接触发。

it's the total time the connection was logged in for, including idle time, so it doesn't indicate a performance problem. Also profiling logins/logouts is very unlikely to cause a performance problem. You'd be better off looking for poorly performing queries, possibly long-running queries.

这是连接登录的总时间,包括空闲时间,因此它并不表示性能问题。此外,分析登录/注销不太可能导致性能问题。您最好寻找性能不佳的查询,可能是长时间运行的查询。

For more info i suggest https://msdn.microsoft.com/en-us/library/ms175827.aspx:)

有关更多信息,我建议https://msdn.microsoft.com/en-us/library/ms175827.aspx:)