sql-server - SQL 连接池和审核登录/注销

标签 sql-server

当我使用 SQL Server Profiler 分析我的应用程序时,我看到大量针对同一数据库连接的审核登录审核注销消息。我想知道,这是否表明我的连接池有问题?我之所以问这个问题,是因为我在 MSDN 文档中找到了有关连接池的内容:

Login and logout events will not be raised on the server when a connection is fetched from or returned to the connection pool. This is because the connection is not actually closed when it is returned to the connection pool. For more information, see Audit Login Event Class and Audit Logout Event Class in SQL Server Books Online.

http://msdn.microsoft.com/en-us/library/8xx3tyca.aspx

此外,是否有人有任何提示来确定连接池对于给定 SQL 服务器的有效性?我在一台服务器上有很多数据库,我知道这会产生巨大的影响,但我想知道是否有一种简单的方法来获取有关连接池有效性的指标。提前致谢!

最佳答案

虽然 MSDN 文章说该事件只会针对非重用连接引发,但 SQL Server 文档与此声明相矛盾:

"The Audit Login event class indicates that a user has successfully logged in to Microsoft SQL Server. Events in this class are fired by new connections or by connections that are reused from a connection pool."

衡量池化有效性的最佳方法是收集使用和不使用池化的连接所花费的时间。通过池化,您应该看到第一个连接很慢,而后续连接则非常快。如果没有池化,每个连接都会花费大量时间。

如果要跟踪审核登录事件,可以使用 EventSubClass 数据列来确定登录是使用重用连接还是新连接。对于实际连接,该值将为 1;对于来自 pool.application 的重用连接,该值为 2。

关于sql-server - SQL 连接池和审核登录/注销,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/279401/

相关文章:

sql - 如果外键表中不存在外键,如何选择记录

sql - 如果我从未提交,是否需要调用回滚?

sql-server - VB.NET 中的 SQL 触发器

mysql - 如何通过本地 Linux 机器截断(删除所有行)远程 SQL 服务器上的表

sql - 获得全部时间

mysql - 余额趋势分析

mysql - 左连接查询和 select 计数在 MySQL 中有效,但在 MS SQL Server 2012 中无效

sql "chain of command"

sql-server - 分区表错误,分区数量多于文件组数量

asp.net - IIS 性能