SQL Server 超时是否被记录?
SQL Server 超时(特别是 SELECT 查询)是否记录在 ERRORLOG 文件中?
背景是一位客户的网站偶尔会出现“请求超时”消息,我认为超时是由数据库超时引起的。 相关错误日志中没有超时错误。
Are SQL Server timeouts (SELECT queries, in particular) logged in the ERRORLOG file?
Background is a customer with a web site having occasional "Request timeout" messages, looking to me assuming that the timeout is caused by a database timeout. There are no timeout errors in the ERRORLOG in question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不可以。您需要使用 SQL Profiler。 具有锁定超时事件和死锁图事件的标准跟踪应该可以做到这一点。
锁定:超时事件类
死锁图事件类
除了硬件之外(例如足够的 RAM 和快速驱动器,以及在适当的 RAID 配置上适当放置数据和日志文件),大多数超时是由于没有适合您的工作负载的足够“好的”索引集而导致。
你们有定期安排索引维护计划吗?
No. You will need to use SQL Profiler. A standard trace with the Lock Timeout event and Deadlock Graph events should do it.
Lock:Timeout Event Class
Deadlock Graph Event Class
Hardware aside (such as enough RAM and fast drives, and appropriate placement of Data and Log files on the appropriate RAID configurations) most timeouts are caused by not having a sufficently 'good' set of indexes for your workload.
Do you have index maintenance plans scheduled regularly?
SQL Server 超时作为注意事件从客户端启动,并且不会记录在 SQL Server 错误日志中。
您可以使用以下方式监视注意事件:
SQL Server timeouts are initiated from the client-side as Attention Events and are not recorded in the SQL Server Error Log.
You can monitor for Attention Events using:
您还可以使用在超时和死锁事件时引发的事件通知。 触发后,您可以将其写入表格或向自己发送电子邮件。
我在这里展示了一般技术:
You could also use Event Notifications that get raised on the timeout and deadlock events. After it fires, you can write it to a table and or send yourself an email.
I've shown the general technique here:
This way you don't have to run Profiler; which can impact performance.