0
我有一種執行以下代碼的方法:爲什麼我的方法在Azure中運行時會卡住?
var subresulta1 = (from s in surveys
select new SurveyViewModel()
{
Id = s.Id,
Name = s.Name.Translation(Language.En),
IsActive = s.IsActive,
Locations = (from l in resulta.Select(a => a.Question.Location).Distinct()
select new LocationViewModel()
{
Id = l.Id,
Name = l.Name.Translation(Language.En),
Questions = (from q in resulta.Select(a => a.Question).Distinct()
where q.LocationId == l.Id
select new QuestionViewModel()
{
Text = q.QuestionText.Translation(Language.En),
Scores = (from a in resulta
where a.QuestionId == q.Id
select new ScoreViewModel()
{
Value = (int) a.Value,
PositionId = a.SurveyAnswers.PositionId,
Date = a.SurveyAnswers.CreatedDate,
Location = new LatLonViewModel()
{
Latitude = a.SurveyAnswers.Latitude,
Longitude = a.SurveyAnswers.Longitude
}
}).ToList()
}).ToList()
}).ToList()
}).ToList();
當我我的測試機(在Windows Server 2008 R2與SQL Server 2012)上運行它,它需要大約3秒即可完成。當我將它作爲連接到Azure SQL DB的應用程序服務運行時,它在~4分鐘後完成。應用服務器定價層是「標準:1大」和數據庫服務器「S2」,所以我猜這些機器的性能不是問題。當然,兩個數據庫中的數據都是一樣的。有沒有人遇到類似的問題?
編輯 我不認爲這是SQL服務器問題。我認爲這是應用程序問題。我重寫了代碼,首先從DB獲取所有數據,然後應用所有邏輯。這完成更快(30秒),但仍然不能與我自己的服務器的性能相媲美。任何想法都非常感謝。
查詢運行時,您需要查找等待狀態 – TheGameiswar
sys.dm_exec_requests – TheGameiswar