“exec sp_reset_connection”是什么意思 在 Sql Server Profiler 中是什么意思?
尝试通过发出“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”,这是否意味着我的连接已关闭?
Trying to understand what Sql Profiler means by emitting "sp_reset_connection".
I have the following, "exec sp_reset_connection" line followed by BatchStarting and 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]
Basically does first line "exec sp_reset_connection" mean the whole process (my connection was opened, the select stmt is run, then the connection is closed and released back to pool) just take place? Or my connection is still in open stage.
And, why does the sp_reset_connection executed before my own select statement, shouldn't it the reset come after user's sql?
I'm trying to know is there a way to know in more detail when a connection is opened and closed?
By seeing "exec sp_reset_connection", does that mean my connection is closed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
就像其他答案所说,sp_reset_connection表示连接池正在被重用。 请注意一个特定的后果!
更新:从 SQL 2014 开始,对于 TDS 版本 7.3 或更高版本的客户端驱动程序,事务隔离级别将重置回默认值。
参考:SQL Server:跨池连接的隔离级别泄漏
此处是一些附加信息:
注意:我将列表包含在此处,因为我不希望它在瞬息万变的网络中丢失。
Like the other answers said,
sp_reset_connection
indicates that connection pool is being reused. Be aware of one particular consequence!UPDATE: Starting with SQL 2014, for client drivers with TDS version 7.3 or higher, the transaction isolation levels will be reset back to the default.
ref: SQL Server: Isolation level leaks across pooled connections
Here is some additional information:
Note: I am including the list here as I do not want it to be lost in the ever transient web.
这表明正在使用连接池(这是一件好事)。
It's an indication that connection pooling is being used (which is a good thing).
但请注意:
如果在存储过程或触发器中发出 SET TRANSACTION ISOLATION LEVEL,则当对象返回控制权时,隔离级别将重置为调用对象时有效的级别。 例如,如果在批处理中设置 REPEATABLE READ,然后该批处理调用将隔离级别设置为 SERIALIZABLE 的存储过程,则当存储过程将控制返回到批处理时,隔离级别设置将恢复为 REPEATABLE READ。
http://msdn.microsoft.com/en-us/library/ms173763.aspx
Note however:
If you issue SET TRANSACTION ISOLATION LEVEL in a stored procedure or trigger, when the object returns control the isolation level is reset to the level in effect when the object was invoked. For example, if you set REPEATABLE READ in a batch, and the batch then calls a stored procedure that sets the isolation level to SERIALIZABLE, the isolation level setting reverts to REPEATABLE READ when the stored procedure returns control to the batch.
http://msdn.microsoft.com/en-us/library/ms173763.aspx