【发布时间】:2016-02-13 03:04:58
【问题描述】:
我一直在使用 ASP.Net WebApp,它需要很长时间才能加载特定的 ASPX 页面。第一次在浏览器中加载页面后,下次在生产中无法替换此问题。
更新
我添加了一些日志,看起来下面的查询需要 1 分 20 秒才能执行。你能帮我优化一下吗?第一次需要这么长时间的查询实际上有什么问题?
日志:
"11/12/15","22:24:24","ExecuteSql - ---4---- ","9",""
"11/12/15","22:25:44","ExecuteSql - ---5---- ","9",""
查询:
SELECT TOP 1 CONVERT(varchar(15), Period_End_Date, 107) as PDate FROM PBHISTORY..STATEMENT_OF_CHANGE ORDER BY Period_End_Date DESC","7",""
C#代码:
公共字符串 GetDateRangeReportingDate(int reportId) { LogActivityVerbose("GetDateRangeReportingDate - 在 GetReportInfoById 之前"); var 报告 = GetReportInfoById(reportId); LogActivityVerbose("GetDateRangeReportingDate - 在 GetReportInfoById 之后");
string sql = string.Format(@"SELECT TOP 1 CONVERT(varchar(15), Period_End_Date, 107) as PDate FROM {0}..{1}
ORDER BY Period_End_Date DESC", _historyDatabase, report.SourceTableName);
LogActivityVerbose("GetDateRangeReportingDate - before ExecuteSql ");
var data = ExecuteSql(sql);
LogActivityVerbose("GetDateRangeReportingDate - after ExecuteSql ");
while (data.Read())
{
return data["PDate"].ToString();
}
return null;
}
【问题讨论】:
标签: c# sql asp.net performance application-pool