简体   繁体   English

Linq to SQL TImeout问题

[英]Linq to Sql TImeout issues

I have a method to pull a user's information using linq to sql classes. 我有一种使用linq将用户信息提取到sql类的方法。 The method executes three queries using linq statements that call existing stored procs. 该方法使用linq语句执行三个查询,这些语句调用现有存储的proc。 Here is an example of how I am laying out my linq statements. 这是我如何布置linq语句的示例。

            using (var db = new TestDataContext(connection)))
            {
                var user = db.proc_UserInfo(userId);

                foreach (var x in user)
                {
                    string FullName = x.FirstName + " " + x.LastName;
                    string Address = x.Addr1;
                    string City = x.City;                        
                }
            }

This method is called through a web api controller which fires from a jquery ajax request. 通过Web api控制器调用此方法,该控制器会从jquery ajax请求中触发。 It works fine but when I put some load on it by hastily changing the dropdown list full of users that makes the ajax request I notice if I can do it fast enough it seems like the batch of queries going to the db are canceled and the calls are suspended for a few minutes the next queries made timeout and return null objects. 它工作正常,但是当我通过匆忙更改充满ajax请求的用户的下拉列表而对其施加一些负载时,我注意到我是否可以足够快地完成它,似乎去往数据库的那批查询被取消了并且调用被暂停几分钟,下一次查询将超时并返回空对象。 One thing to note these queries are not returning but a few rows of data. 要注意的一件事是这些查询没有返回,而是几行数据。 I'm still trying to figure out what is going on and am open to suggestions. 我仍在尝试找出正在发生的事情,并欢迎提出建议。 Thanks in advance. 提前致谢。

First of I think people may need a little more information. 首先,我认为人们可能需要更多信息。 Database type I assume is SQL Server but you havent listed a version yet. 我认为数据库类型是SQL Server,但您尚未列出版本。 In any case, it may be a few things. 无论如何,这可能是几件事。 Remember AJAX calls are running as a http request / post so there may be IIS timeouts or other various IIS limitations there. 请记住,AJAX调用是作为http请求/帖子运行的,因此那里可能存在IIS超时或其他各种IIS限制。 Also, are your calls asynchronous etc. Jquery has some settings you may want to verify. 另外,您的呼叫是否异步等。jQuery可能需要验证某些设置。 Table locking is SQL Server is also a possibility. 表锁定也是SQL Server的一种可能。 Also check your browser ram / w3wp usage to make sure its not running out of resources. 还要检查您的浏览器ram / w3wp的使用情况,以确保其不会耗尽资源。

First off I suggest running SQL Profiler to verify whats going on, then check the execution plans of those queries. 首先,我建议运行SQL事件探查器以验证发生了什么,然后检查这些查询的执行计划。 If theres a large amount of data, you may need some indexing. 如果有大量数据,则可能需要一些索引。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM