- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
尝试通过发出“sp_reset_connection”来理解 Sql Profiler 的含义。
我有以下“exec sp_reset_connection”行,后跟 BatchStarting 和 Completed,
RPC:Completed exec sp_reset_connection
SQL:BatchStarting SELECT [c].[TestID] AS [TestID], [c].[Description] AS [Description] FROM [dbo].[Test] AS [c]
SQL:BatchCompleted SELECT [c].[TestID] AS [TestID], [c].[Description] AS [Description] FROM [dbo].[Test] AS [c]
基本上第一行“exec sp_reset_connection”意味着整个过程(我的连接被打开,select stmt运行,然后连接被关闭并释放回池)刚刚发生?或者我的连接仍处于开放阶段。
而且,为什么 sp_reset_connection 在我自己的 select 语句之前执行,难道重置不应该在用户的 sql 之后执行吗?
我想知道是否有办法更详细地了解连接何时打开和关闭?
看到“exec sp_reset_connection”,是否意味着我的连接已关闭?
最佳答案
就像其他答案所说,sp_reset_connection
表示连接池正在被重用。请注意一个特定的后果!
Jimmy Mays' MSDN Blog said:
sp_reset_connection does NOT reset thetransaction isolation level to theserver default from the previousconnection's setting.
更新:从 SQL 2014 开始,对于 TDS 版本 7.3 或更高版本的客户端驱动程序,事务隔离级别将重置回默认值。
引用:SQL Server: Isolation level leaks across pooled connections
以下是一些附加信息:
What does sp_reset_connection do?
Data access API's layers like ODBC,OLE-DB and System.Data.SqlClient allcall the (internal) stored proceduresp_reset_connection when re-using aconnection from a connection pool. Itdoes this to reset the state of theconnection before it gets re-used,however nowhere is documented whatthings get reset. This article triesto document the parts of theconnection that get reset.
sp_reset_connection resets thefollowing aspects of a connection:
All error states and numbers(like @@error)
Stops all EC's (execution contexts)that are child threads of a parent ECexecuting a parallel query
Waits for any outstanding I/Ooperations that is outstanding
Frees any held buffers on theserver by the connection
Unlocks any buffer resourcesthat are used by the connection
Releases all allocated memoryowned by the connection
Clears any work or temporarytables that are created by theconnection
Kills all global cursors owned by theconnection
Closes any open SQL-XML handles that are open
Deletes any open SQL-XML related work tables
Closes all system tables
Closes all user tables
Drops all temporary objects
Aborts open transactions
Defects from a distributed transaction when enlisted
Decrements the reference countfor users in current database whichreleases shared database locks
Frees acquired locks
Releases any acquired handles
Resets all SET options to the default values
Resets the @@rowcount value
Resets the @@identity value
Resets any session level traceoptions using dbcc traceon()
Resets CONTEXT_INFO to
NULL
in SQL Server 2005 and newer [ not part of the original article ]sp_reset_connection will NOT reset:
Security context, which is whyconnection pooling matches connectionsbased on the exact connection string
Application roles entered using sp_setapprole, since application roles could not be reverted at all prior to SQL Server 2005. Starting in SQL Server 2005, app roles can be reverted, but only with additional information that is not part of the session. Before closing the connection, application roles need to be manually reverted via sp_unsetapprole using a "cookie" value that is captured when
sp_setapprole
is executed.
注意:我将列表包含在此处,因为我不希望它在瞬息万变的网络中丢失。
关于sql-server - "exec sp_reset_connection"在 Sql Server Profiler 中意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/641120/
由于我遇到了一些问题,我正在 .NET Framework 4 中尝试连接池。使用 SQL Profiler,我可以看到每次从连接池中获取连接时,都会执行存储过程 sp_reset_connectio
sp_reset_connection 似乎由 SQL Server 连接池调用,以确保从池中重用的连接重置大部分设置。有谁确切知道它做什么和不做什么? 例如我从 this post 看到它不会重置事
我的分析器跟踪显示 exec sp_reset_connection在每个 sql 批处理或过程调用之间调用。有reasons for it ,但是如果我确信它是不必要的,我可以防止它被调用以提高性能
我有一个 .NET 4.0 Winform 和一个 .NET 4.0 Windows 服务,它们都通过 LINQ to SQL 连接到 SQL 2005/2008 数据库。它在我们的测试环境中运行良好
这个问题已经有答案了: What does sp_reset_connection do? (2 个回答) 已关闭 4 年前。 社区去年审查了是否重新开放此问题,并将其关闭: 原始关闭原因未解决 尝试
根据我读到的有关“exec sp_reset_connection”的信息,当连接池存在时,它出现在 SQL Server Profiler 跟踪数据中,从要考虑的跟踪数据中删除/排除它似乎是安全的(
我是一名优秀的程序员,十分优秀!