未加星标

SQL Server Understanding Connection Timeouts and Query Timeouts

字体大小 | |
[数据库(mssql) 所属分类 数据库(mssql) | 发布者 店小二04 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏

Have you ever got into a situation wherein you feel you see something and work for a solution in a completely opposite direction? Recently I was out of the country for a session and at the breakfast table I found a dark red bottle of ketchup which I used for my sandwich. Lesser did I know it was actually a spicy sauce. And on closer look this time, I found the mistake I did and how I ruined my whole breakfast. These are times when you oversee something which looks like one and you land up as something completely different. This blog post we will beUnderstanding Connection Timeouts and Query Timeouts.


SQL Server   Understanding Connection Timeouts and Query Timeouts

During consultancy there are times when you are as an open book of all kinds of questions. When I was at a customer location, I was confronted by something simple. The developer walked up to me and said he had a question related to SQL Server. Eager to hear, I asked the problem statement. He said he wanted to show me a code block.

System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

Now this is one of the generic error which you can ever get. I was trying to explain him how the errors and settings are when working with such error. I wanted to look at the time when the error comes. At this moment you need to understand the reason. Let us look at what the defaults are for our timeouts to put some context around this. These numbers can be adjusted in different ways. Either through code, or a connection string for example.

Connection Timeout setting: 15 Seconds

Command/Query Timeout Setting: 30 Seconds

Interestingly, with this rule of thumb and since he was using the default I could guess he was getting Query Timeout in his code. I went on to talk how being on the latest and greatest would have easily solved him the problem. He was not sure what I meant. Since he was on .NET 2.0, we both walked to another machine with .NET 4.5 installed and I we wrote a simple code to see how it would work. We tried to get a stack dump too, as part of it. Now keeping the specifics apart, we got:

System.Data.SqlClient.SqlException: Connection Timeout Expired. The timeout period elapsed while …

And when we encountered Query Timeout it read like:

System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior …

Sometimes we see such interesting arguments on why upgrading is better or not. I was with my limited knowledge easily know how he can get productivity as a developer by moving to the latest and greatest of the platform. I know I have limited knowledge on .NET but this is something I remember seeing in one of the sessions at the Bangalore User Group by the connectivity engineer. This stuck in my mind for a long time and it came handy big time.

After I found his problem statement. I was delighted. I told him not to change any of the default settings. Since his problem was a query timeout, I wanted to look at the query that was running behind and why it was taking more than normal acceptable time on his system. This was a great way for me to solve something in the application and later start tuning the SQL Server in their environment.

Reference: Pinal Dave ( http://blog.sqlauthority.com )

本文数据库(mssql)相关术语:熊片数据库 mssql数据库 oracle数据库 pubmed数据库 access数据库 万方数据库

主题: SQLSQL Server
分页:12
转载请注明
本文标题:SQL Server Understanding Connection Timeouts and Query Timeouts
本站链接:http://www.codesec.net/view/483562.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 数据库(mssql) | 评论(0) | 阅读(23)